@jkba/eslint-config-angular 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,6 +20,7 @@ npm i -D \
20
20
  eslint-import-resolver-typescript \
21
21
  @eslint/js \
22
22
  typescript-eslint \
23
+ @smarttools/eslint-plugin-rxjs \
23
24
  @jkba/eslint-config-angular
24
25
 
25
26
  ```
package/eslint.config.js CHANGED
@@ -5,10 +5,9 @@ const tseslint = require('typescript-eslint');
5
5
  const angular = require('angular-eslint');
6
6
  const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
7
7
  const importPlugin = require('eslint-plugin-import');
8
+ const rxjs = require('@smarttools/eslint-plugin-rxjs');
8
9
 
9
10
  const config = tseslint.config(
10
- eslint.configs.recommended,
11
- tseslint.configs.recommended,
12
11
  {
13
12
  files: ['**/*.ts'],
14
13
  processor: angular.processInlineTemplates,
@@ -17,31 +16,141 @@ const config = tseslint.config(
17
16
  tseslint.configs.stylisticTypeChecked,
18
17
  tseslint.configs.strictTypeChecked,
19
18
  angular.configs.tsRecommended,
19
+ // TODO
20
20
  // 'plugin:rxjs/recommended', // For some unknown weird reason, this plugin needs to be installed in child project as well.
21
21
  importPlugin.flatConfigs?.recommended,
22
22
  importPlugin.flatConfigs?.typescript,
23
23
  ],
24
+ plugins: { rxjs },
24
25
  settings: {
25
26
  // Reference https://www.npmjs.com/package/eslint-plugin-import
26
27
  'import/resolver': {
27
28
  // You will also need to install and configure the TypeScript resolver
28
29
  // See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
29
- 'typescript': true,
30
- 'node': true,
31
- }
32
- }
30
+ typescript: true,
31
+ node: true,
32
+ },
33
+ },
34
+ rules: {
35
+ 'no-implicit-coercion': 'error',
36
+ 'no-self-compare': 'error',
37
+ 'no-unmodified-loop-condition': 'error',
38
+ 'no-unreachable-loop': 'error',
39
+ 'default-case': 'warn',
40
+ eqeqeq: 'error',
41
+ 'max-classes-per-file': 'error',
42
+ 'no-warning-comments': ['error', { terms: ['todo', 'fixme'], location: 'anywhere' }],
43
+ 'no-console': 'error',
44
+ 'prefer-template': 'error',
45
+ 'arrow-body-style': ['error', 'as-needed'],
46
+
47
+ /**
48
+ * Declaration sort is handled by import/order rule.
49
+ * This rule handles order within {}-brackets only.
50
+ */
51
+ 'sort-imports': ['error', { ignoreDeclarationSort: true }],
52
+
53
+ /**
54
+ * Handled by https://typescript-eslint.io/rules/no-unused-vars/
55
+ * You must disable the base rule as it can report incorrect errors
56
+ */
57
+ 'no-unused-vars': 'off',
58
+
59
+ // Reference https://github.com/cartant/eslint-plugin-rxjs/blob/main/docs/rules/finnish.md
60
+ 'rxjs/finnish': [
61
+ 'error',
62
+ {
63
+ functions: false,
64
+ methods: false,
65
+ names: {
66
+ '^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate)$': false,
67
+ },
68
+ parameters: true,
69
+ properties: true,
70
+ strict: false,
71
+ types: {
72
+ '^EventEmitter$': false,
73
+ '^Store$': false,
74
+ },
75
+ variables: true,
76
+ },
77
+ ],
78
+ 'rxjs/no-exposed-subjects': ['error', { allowProtected: true }],
79
+ 'rxjs/no-compat': 'error',
80
+ 'rxjs/throw-error': 'error',
81
+
82
+ '@typescript-eslint/no-unused-vars': ['error', { args: 'after-used' }],
83
+ '@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }], // Ignore `Validators.required` etc.
84
+ '@typescript-eslint/no-confusing-void-expression': 'off', // I just simply disagree with this rule
85
+ '@typescript-eslint/explicit-member-accessibility': [
86
+ 'error',
87
+ { overrides: { constructors: 'no-public' } },
88
+ ],
89
+ '@typescript-eslint/prefer-optional-chain': 'error',
90
+
91
+ '@angular-eslint/no-input-rename': 'off', // I just simply disagree with this rule. Especially while using "transform" property.
92
+ '@angular-eslint/prefer-on-push-component-change-detection': 'error',
93
+ '@angular-eslint/use-component-view-encapsulation': 'warn', // For me, it is only a suggestion
94
+ '@angular-eslint/prefer-output-readonly': 'error', // TODO: https://github.com/jmeinlschmidt/eslint-config-angular/issues/14
95
+ '@angular-eslint/contextual-decorator': 'error',
96
+ '@angular-eslint/component-max-inline-declarations': ['error', { template: 20 }],
97
+ '@angular-eslint/no-attribute-decorator': 'error',
98
+ '@angular-eslint/no-conflicting-lifecycle': 'error',
99
+ '@angular-eslint/no-empty-lifecycle-method': 'error',
100
+ '@angular-eslint/no-forward-ref': 'warn', // For me, it is only a suggestion
101
+ '@angular-eslint/no-input-prefix': 'error',
102
+ '@angular-eslint/no-lifecycle-call': 'error',
103
+ '@angular-eslint/no-pipe-impure': 'error',
104
+ '@angular-eslint/no-queries-metadata-property': 'error',
105
+ '@angular-eslint/prefer-standalone': 'error',
106
+ '@angular-eslint/prefer-signals': 'error',
107
+ '@angular-eslint/relative-url-prefix': 'error',
108
+ // '@angular-eslint/require-localize-metadata': 'error', // TODO: https://github.com/jmeinlschmidt/eslint-config-angular/issues/13
109
+ '@angular-eslint/use-component-selector': 'error',
110
+ '@angular-eslint/component-selector': [
111
+ 'error',
112
+ {
113
+ type: 'element',
114
+ prefix: 'app',
115
+ style: 'kebab-case',
116
+ },
117
+ ],
118
+ '@angular-eslint/directive-selector': [
119
+ 'error',
120
+ {
121
+ type: 'attribute',
122
+ prefix: 'app',
123
+ style: 'kebab-case', // I just don't really agree with using camelCase. Material isn't using it neither.
124
+ },
125
+ ],
126
+
127
+ 'import/no-absolute-path': 'error',
128
+ 'import/newline-after-import': ['error', { count: 1 }],
129
+ 'import/order': [
130
+ 'error',
131
+ {
132
+ groups: [['builtin', 'external'], 'internal', 'parent', 'sibling', 'index'],
133
+ 'newlines-between': 'always',
134
+ alphabetize: {
135
+ order: 'asc',
136
+ caseInsensitive: true,
137
+ },
138
+ },
139
+ ],
140
+ 'import/no-useless-path-segments': ['error', { noUselessIndex: true }],
141
+ // 'import/no-deprecated': 'error', // Throws false-positive for RxJS,
142
+ 'import/no-self-import': 'error',
143
+ },
33
144
  },
34
145
  {
35
146
  files: ['**/*.html'],
36
- extends: [
37
- ...angular.configs.templateRecommended,
38
- ...angular.configs.templateAccessibility,
39
- ],
147
+ extends: [...angular.configs.templateRecommended, ...angular.configs.templateAccessibility],
40
148
  rules: {
41
149
  '@angular-eslint/template/attributes-order': 'error',
42
150
  '@angular-eslint/template/no-inline-styles': 'warn', // For me, it is only a suggestion
43
151
  '@angular-eslint/template/conditional-complexity': [
44
- 'error', { 'maxComplexity': 3 } // Max 3 is enough, create derived variable with proper naming
152
+ 'error',
153
+ { maxComplexity: 3 }, // Max 3 is enough, create derived variable with proper naming
45
154
  ],
46
155
  '@angular-eslint/template/i18n': 'error',
47
156
  '@angular-eslint/template/no-any': 'error',
@@ -49,12 +158,12 @@ const config = tseslint.config(
49
158
  '@angular-eslint/template/no-interpolation-in-attributes': 'error',
50
159
  '@angular-eslint/template/prefer-self-closing-tags': 'error',
51
160
  '@angular-eslint/template/use-track-by-function': 'error',
52
- '@angular-eslint/template/prefer-control-flow': 'error'
161
+ '@angular-eslint/template/prefer-control-flow': 'error',
53
162
  },
54
163
  },
55
164
  // Prettier rule must always be the very last!
56
165
  // This rule might intentionally disable some rules declared above due to conflicts
57
- eslintPluginPrettierRecommended
166
+ eslintPluginPrettierRecommended,
58
167
  );
59
168
 
60
169
  module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jkba/eslint-config-angular",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Opinionated ESLint config for Angular projects",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -41,6 +41,7 @@
41
41
  "eslint-plugin-prettier": ">=5",
42
42
  "prettier": ">=3",
43
43
  "typescript": ">=4",
44
- "typescript-eslint": "^8"
44
+ "typescript-eslint": "^8",
45
+ "@smarttools/eslint-plugin-rxjs": "^1.0.0"
45
46
  }
46
47
  }