Skip to content

Commit d8f5493

Browse files
committed
fix(eslint-plugin-experience-next): use strict rules
1 parent 9cb4231 commit d8f5493

File tree

4 files changed

+83
-11
lines changed

4 files changed

+83
-11
lines changed

projects/eslint-plugin-experience-next/configs/recommended.ts

+73-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const modernAngularRules = {
4040
};
4141

4242
try {
43-
const major = require('@angular/cli').VERSION.major;
43+
const {major} = require('@angular/cli').VERSION;
4444

4545
angularVersion = parseInt(major, 10);
4646
} catch {}
@@ -94,7 +94,7 @@ export default tseslint.config(
9494
],
9595
},
9696
eslint.configs.recommended,
97-
tseslint.configs.recommended,
97+
tseslint.configs.all,
9898
require('eslint-config-prettier'),
9999
{
100100
files: ['**/*.ts', '**/*.js'],
@@ -112,8 +112,7 @@ export default tseslint.config(
112112
},
113113
extends: [
114114
eslint.configs.recommended,
115-
...tseslint.configs.recommended,
116-
...tseslint.configs.stylistic,
115+
...tseslint.configs.all,
117116
...angular.configs.tsRecommended,
118117
],
119118
languageOptions: {
@@ -546,6 +545,12 @@ export default tseslint.config(
546545
'@typescript-eslint/no-useless-constructor': 'error',
547546
'@typescript-eslint/no-var-requires': 'error',
548547
'@typescript-eslint/only-throw-error': 'error',
548+
'@typescript-eslint/parameter-properties': [
549+
'error',
550+
{
551+
allow: ['public readonly', 'protected readonly', 'private readonly'],
552+
},
553+
],
549554
'@typescript-eslint/prefer-as-const': 'error',
550555
'@typescript-eslint/prefer-find': 'error',
551556
'@typescript-eslint/prefer-for-of': 'error',
@@ -886,6 +891,8 @@ export default tseslint.config(
886891
...angular.configs.templateAccessibility,
887892
],
888893
rules: {
894+
'@typescript-eslint/no-confusing-void-expression': 'off',
895+
'@typescript-eslint/no-meaningless-void-operator': 'off',
889896
'@angular-eslint/template/interactive-supports-focus': 'off',
890897
'@angular-eslint/template/label-has-associated-control': 'off',
891898
'@angular-eslint/template/no-distracting-elements': 'error',
@@ -894,7 +901,51 @@ export default tseslint.config(
894901
'@angular-eslint/template/prefer-control-flow':
895902
angularVersion >= modernAngularRules.preferControlFlow ? 'error' : 'off',
896903
'@angular-eslint/template/prefer-self-closing-tags': 'error',
904+
'@typescript-eslint/await-thenable': 'off',
897905
'@typescript-eslint/ban-ts-comment': 'off',
906+
'@typescript-eslint/consistent-type-exports': 'off',
907+
'@typescript-eslint/consistent-type-imports': 'off',
908+
'@typescript-eslint/dot-notation': 'off',
909+
'@typescript-eslint/naming-convention': 'off',
910+
'@typescript-eslint/no-array-delete': 'off',
911+
'@typescript-eslint/no-duplicate-type-constituents': 'off',
912+
'@typescript-eslint/no-implied-eval': 'off',
913+
'@typescript-eslint/no-misused-promises': 'off',
914+
'@typescript-eslint/no-mixed-enums': 'off',
915+
'@typescript-eslint/no-redundant-type-constituents': 'off',
916+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
917+
'@typescript-eslint/no-unnecessary-qualifier': 'off',
918+
'@typescript-eslint/no-unnecessary-template-expression': 'off',
919+
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
920+
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
921+
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
922+
'@typescript-eslint/no-unsafe-argument': 'off',
923+
'@typescript-eslint/no-unsafe-assignment': 'off',
924+
'@typescript-eslint/no-unsafe-call': 'off',
925+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
926+
'@typescript-eslint/no-unsafe-type-assertion': 'off',
927+
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
928+
'@typescript-eslint/only-throw-error': 'off',
929+
'@typescript-eslint/prefer-destructuring': 'off',
930+
'@typescript-eslint/prefer-find': 'off',
931+
'@typescript-eslint/prefer-includes': 'off',
932+
'@typescript-eslint/prefer-optional-chain': 'off',
933+
'@typescript-eslint/prefer-promise-reject-errors': 'off',
934+
'@typescript-eslint/prefer-readonly': 'off',
935+
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
936+
'@typescript-eslint/prefer-regexp-exec': 'off',
937+
'@typescript-eslint/prefer-return-this-type': 'off',
938+
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
939+
'@typescript-eslint/promise-function-async': 'off',
940+
'@typescript-eslint/related-getter-setter-pairs': 'off',
941+
'@typescript-eslint/require-array-sort-compare': 'off',
942+
'@typescript-eslint/require-await': 'off',
943+
'@typescript-eslint/restrict-plus-operands': 'off',
944+
'@typescript-eslint/restrict-template-expressions': 'off',
945+
'@typescript-eslint/return-await': 'off',
946+
'@typescript-eslint/switch-exhaustiveness-check': 'off',
947+
'@typescript-eslint/unbound-method': 'off',
948+
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
898949
'import/namespace': 'off',
899950
},
900951
},
@@ -997,6 +1048,9 @@ export default tseslint.config(
9971048
files: ['**/*'],
9981049
rules: {
9991050
'@angular-eslint/use-injectable-provided-in': 'off',
1051+
'@typescript-eslint/no-confusing-void-expression': 'off',
1052+
'@typescript-eslint/no-invalid-this': 'off',
1053+
'@typescript-eslint/no-invalid-void-type': 'off',
10001054
'sonarjs/no-invalid-await': 'off',
10011055
'@angular-eslint/component-class-suffix': 'off',
10021056
'@angular-eslint/component-max-inline-declarations': 'off',
@@ -1018,21 +1072,36 @@ export default tseslint.config(
10181072
'@typescript-eslint/adjacent-overload-signatures': 'off',
10191073
'@typescript-eslint/ban-ts-comment': 'off',
10201074
'@typescript-eslint/class-literal-property-style': 'off',
1075+
'@typescript-eslint/class-methods-use-this': 'off',
10211076
'@typescript-eslint/consistent-return': 'off',
10221077
'@typescript-eslint/explicit-module-boundary-types': 'off',
1078+
'@typescript-eslint/init-declarations': 'off',
1079+
'@typescript-eslint/method-signature-style': 'off',
10231080
'@typescript-eslint/no-base-to-string': 'off',
1081+
'@typescript-eslint/no-deprecated': 'off',
10241082
'@typescript-eslint/no-explicit-any': 'off',
10251083
'@typescript-eslint/no-floating-promises': 'off',
1084+
'@typescript-eslint/no-magic-numbers': 'off',
1085+
'@typescript-eslint/no-misused-promises': 'off',
1086+
'@typescript-eslint/no-misused-spread': 'off',
10261087
'@typescript-eslint/no-non-null-assertion': 'off',
10271088
'@typescript-eslint/no-require-imports': 'off',
10281089
'@typescript-eslint/no-shadow': 'off',
10291090
'@typescript-eslint/no-unnecessary-condition': 'off',
1091+
'@typescript-eslint/no-unnecessary-template-expression': 'off',
1092+
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
1093+
'@typescript-eslint/no-unsafe-argument': 'off',
1094+
'@typescript-eslint/no-unsafe-assignment': 'off',
1095+
'@typescript-eslint/no-unsafe-call': 'off',
10301096
'@typescript-eslint/no-unsafe-member-access': 'off',
10311097
'@typescript-eslint/no-unsafe-return': 'off',
1098+
'@typescript-eslint/no-unsafe-type-assertion': 'off',
10321099
'@typescript-eslint/no-var-requires': 'off',
1100+
'@typescript-eslint/prefer-destructuring': 'off',
10331101
'@typescript-eslint/prefer-nullish-coalescing': 'off',
10341102
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
10351103
'@typescript-eslint/strict-boolean-expressions': 'off',
1104+
'@typescript-eslint/unbound-method': 'off',
10361105
camelcase: 'off',
10371106
'class-methods-use-this': 'off',
10381107
complexity: 'off',

projects/eslint-plugin-experience-next/rules/decorator-key-sort.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const config: Rule.RuleModule = {
99
const decorators: any[] = Array.from((node as any).decorators ?? []);
1010

1111
decorators.forEach((decorator) => {
12-
const expression = decorator.expression;
12+
const {expression} = decorator;
1313
const decoratorName = expression.callee?.name ?? '';
1414

1515
if (decoratorName in (ORDER || {})) {
@@ -43,9 +43,12 @@ const config: Rule.RuleModule = {
4343
(prop: any) => prop.key.name === key,
4444
),
4545
);
46-
const newDecoratorArgument = `{${sortedDecoratorProperties.map(
47-
({range}: any) => fileContent.slice(...range),
48-
)}}`;
46+
47+
const newDecoratorArgument = `{${sortedDecoratorProperties
48+
.map(({range}: any) =>
49+
fileContent.slice(...range),
50+
)
51+
.toString()}}`;
4952

5053
return fixer.replaceTextRange(
5154
argument.range,

projects/eslint-plugin-experience-next/rules/no-deep-imports.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const config: Rule.RuleModule = {
3131

3232
const isInsideTheSameEntryPoint = (source: string): boolean => {
3333
const filePath = path
34-
.relative(context.getCwd(), context.getFilename())
34+
.relative(context.cwd, context.filename)
3535
.replaceAll(/\\+/g, '/');
3636

3737
const [currentFileProjectName] =

projects/eslint-plugin-experience-next/rules/standalone-imports-sort.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const config: Rule.RuleModule = {
66
ClassDeclaration(node) {
77
const decorators = Array.from((node as any).decorators ?? []);
88

9-
decorators.forEach((decorator) => {
10-
const expression = (decorator as any).expression;
9+
decorators.forEach((decorator: any) => {
10+
const {expression} = decorator;
1111
const decoratorArguments = Array.from(expression.arguments ?? []);
1212

1313
for (const argument of decoratorArguments) {

0 commit comments

Comments
 (0)