eslint-config-beslogic 1.2.0 → 1.3.2

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/.eslintrc.js CHANGED
@@ -2,28 +2,26 @@ module.exports = {
2
2
  "root": true,
3
3
  "env": {
4
4
  "node": true,
5
- "es2021": true,
5
+ "es2021": true
6
6
  },
7
- "plugins": [
8
- "eslint-plugin",
9
- ],
7
+ "plugins": ["eslint-plugin"],
10
8
  "extends": [
11
9
  "./javascript",
12
10
  "plugin:eslint-plugin/all",
11
+ "./json-like"
13
12
  ],
14
13
  "parserOptions": {
15
- "sourceType": "script",
14
+ "sourceType": "script"
16
15
  },
17
16
  "rules": {
18
17
  "unicorn/filename-case": [
19
18
  "error",
20
19
  {
21
- "case": "kebabCase",
22
- },
20
+ "case": "kebabCase"
21
+ }
23
22
  ],
24
23
  "max-len": "off",
25
24
  "max-lines": "off",
26
- "no-magic-numbers": "off",
27
- "quotes": ["error","double"],
28
- },
25
+ "no-magic-numbers": "off"
26
+ }
29
27
  }
package/.used-by.ini CHANGED
@@ -4,5 +4,5 @@ Beslogic.Operations.BesOperationsUI=https://dev.azure.com/Beslogic/BesOperations
4
4
  RateMyDay=https://dev.azure.com/Beslogic/Changent.io/_git/RateMyDay # Rate My Day
5
5
  # External
6
6
  releese_stack=https://github.com/releese-innovations/releese_stack # Releese
7
- speedrun.com_global_scoreboard_webapp=https://github.com/Avasam/speedrun.com_global_scoreboard_webapp # Global Speedrunnign Scoreboard
7
+ speedrun.com_global_scoreboard_webapp=https://github.com/Avasam/speedrun.com_global_scoreboard_webapp # Global Speedrunning Scoreboard
8
8
  troupon-frontend=https://dev.azure.com/PrattAndWhitneyCanada/DT%20LAB/_git/troupon-frontend # Troupon
@@ -20,7 +20,9 @@
20
20
  "coenraads.bracket-pair-colorizer-2",
21
21
  // Lots of conflicts
22
22
  "esbenp.prettier-vscode",
23
- // The ESLint plugin is sufficient in JS-only projects
23
+ // Use workspace version instead
24
+ // "ms-vscode.vscode-typescript-next",
25
+ // The ESLint plugin is sufficient in JS/TS projects
24
26
  "sonarsource.sonarlint-vscode",
25
27
  // Everything below is Deprecated
26
28
  "coenraads.bracket-pair-colorizer",
@@ -20,27 +20,40 @@
20
20
  "editor.tabSize": 2,
21
21
  "editor.insertSpaces": true,
22
22
  "editor.formatOnSave": true,
23
+ // Specify the formatter in case other formatters are also installed (ie: Prettier)
24
+ "[json]": {
25
+ "editor.defaultFormatter": "vscode.json-language-features",
26
+ },
27
+ "[jsonc]": {
28
+ "editor.defaultFormatter": "vscode.json-language-features",
29
+ },
23
30
  "[javascript]": {
24
- "editor.defaultFormatter": "dbaeumer.vscode-eslint",
31
+ "editor.defaultFormatter": "vscode.typescript-language-features",
25
32
  },
26
33
  "[javascriptreact]": {
27
- "editor.defaultFormatter": "dbaeumer.vscode-eslint",
34
+ "editor.defaultFormatter": "vscode.typescript-language-features",
28
35
  },
29
36
  "[typescript]": {
30
- "editor.defaultFormatter": "dbaeumer.vscode-eslint",
37
+ "editor.defaultFormatter": "vscode.typescript-language-features",
31
38
  },
32
39
  "[typescriptreact]": {
33
- "editor.defaultFormatter": "dbaeumer.vscode-eslint",
40
+ "editor.defaultFormatter": "vscode.typescript-language-features",
41
+ },
42
+ "[html]": {
43
+ "editor.defaultFormatter": "vscode.html-language-features",
34
44
  },
35
45
  "editor.codeActionsOnSave": {
36
46
  "source.fixAll": true,
37
47
  },
48
+ "js/ts.implicitProjectConfig.checkJs": true,
38
49
  "javascript.preferences.quoteStyle": "single",
39
50
  "typescript.preferences.quoteStyle": "single",
40
51
  "html.format.wrapAttributes": "force-expand-multiline",
41
52
  "javascript.format.semicolons": "remove",
42
53
  "typescript.format.semicolons": "remove",
43
54
  // For Angular: "typescript.format.semicolons": "insert",
55
+ "javascript.preferences.importModuleSpecifier": "non-relative",
56
+ "typescript.preferences.importModuleSpecifier": "non-relative",
44
57
  "eslint.validate": [
45
58
  "javascript",
46
59
  "javascriptreact",
@@ -53,7 +66,12 @@
53
66
  "mode": "auto"
54
67
  }
55
68
  ],
56
- "eslint.rules.customizations": [{ "rule": "*", "severity": "downgrade" }],
69
+ "eslint.rules.customizations": [
70
+ {
71
+ "rule": "*",
72
+ "severity": "downgrade"
73
+ }
74
+ ],
57
75
  "files.eol": "\n",
58
76
  "files.insertFinalNewline": true,
59
77
  "files.exclude": {
@@ -71,8 +89,6 @@
71
89
  "package-lock.json": true,
72
90
  "*.lock": true,
73
91
  },
74
- "javascript.preferences.importModuleSpecifier": "non-relative",
75
- "typescript.preferences.importModuleSpecifier": "non-relative",
76
92
  "editor.bracketPairColorization.enabled": true,
77
93
  "trailing-spaces.includeEmptyLines": true,
78
94
  "trailing-spaces.trimOnSave": true,
package/README.md CHANGED
@@ -17,9 +17,13 @@ Below are all the different configurations you can extend from. You can mix and
17
17
 
18
18
  Default preset, extends from `beslogic/javascript` and `beslogic/typescript`.
19
19
 
20
+ ### `beslogic/jest`
21
+
22
+ [Jest](https://www.npmjs.com/package/jest) and [Testing Library](https://testing-library.com/) configs. Is already extended by `beslogic/javascript` and `beslogic/typescript` for all `*spec.[jt]s` and `*.test.[jt]sx` files. You should not need to extend from this configuration unless you want to add it to a test file that is not automatically picked up by the naming convention.
23
+
20
24
  ### `beslogic/javascript`
21
25
 
22
- Basic javascript configs, is extended by all other configs except `beslogic/typescript`.
26
+ Basic javascript configs, is extended by all other configs except `beslogic/typescript` and `beslogic/json-like`.
23
27
 
24
28
  ### `beslogic/typescript`
25
29
 
@@ -30,6 +34,9 @@ For the linting to be fully effective, please make sure to set the following in
30
34
  ```json
31
35
  "compilerOptions": {
32
36
  "strict": true,
37
+ "forceConsistentCasingInFileNames": true,
38
+ "noFallthroughCasesInSwitch": true,
39
+ "noImplicitReturns": true,
33
40
  "module": "esnext", // or commonjs
34
41
  "target": "es2017", // or higher
35
42
  "lib": [
@@ -37,7 +44,7 @@ For the linting to be fully effective, please make sure to set the following in
37
44
  "dom",
38
45
  "dom.iterable",
39
46
  ],
40
- }
47
+ },
41
48
  ```
42
49
 
43
50
  and the following engines in your `package.json`:
@@ -80,7 +87,7 @@ Configurations for NGX projects. Comes with `html` template and inline template
80
87
 
81
88
  For the linting to be fully effective, please make sure to set the following in your `tsconfig.json`:
82
89
 
83
- ```json
90
+ ```jsonc
84
91
  "angularCompilerOptions": {
85
92
  // "strictMetadataEmit": true, // For bundling with an npm package
86
93
  "strictInjectionParameters": true,
@@ -95,3 +102,7 @@ For the linting to be fully effective, please make sure to set the following in
95
102
  ### `beslogic/storybook`
96
103
 
97
104
  Includes strict Storybook ESLint plugin and a custom rule for Angular components. This preset should be added last.
105
+
106
+ ### `beslogic/json-like`
107
+
108
+ Enforces stylistic rules for JS objects to look like valid JSON objects.
package/angular.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-ignore
1
2
  const preventAbbreviationsConfig = { ...require("./javascript").rules["unicorn/prevent-abbreviations"][1] }
2
3
  // supported Refs
3
4
  preventAbbreviationsConfig.allowList.Ref = true
@@ -9,40 +10,106 @@ const end2endPreventAbbreviationsConfig = { ...preventAbbreviationsConfig }
9
10
  // eslint-disable-next-line id-length
10
11
  end2endPreventAbbreviationsConfig.allowList.e = true
11
12
  const preferArrowFunctionsConfig = require("./javascript").rules["prefer-arrow/prefer-arrow-functions"][1]
12
-
13
+ const baseIgnoreAttributes = [
14
+ "charset",
15
+ "class",
16
+ "color",
17
+ "colspan",
18
+ "fill",
19
+ "formControlName",
20
+ "height",
21
+ "href",
22
+ "id",
23
+ "lang",
24
+ "ngClass",
25
+ "ngProjectAs",
26
+ "routerLink",
27
+ "src",
28
+ "stroke",
29
+ "stroke-width",
30
+ "style",
31
+ "svgIcon",
32
+ "tabindex",
33
+ "target",
34
+ "type",
35
+ "viewBox",
36
+ "width",
37
+ "xmlns"
38
+ ]
13
39
  module.exports = {
14
- overrides: [
40
+ "overrides": [
15
41
  {
16
- files: ["*.html"],
17
- extends: ["plugin:@angular-eslint/template/recommended"],
42
+ "files": ["*.html"],
43
+ "extends": ["plugin:@angular-eslint/template/all"],
18
44
  "rules": {
45
+ "@angular-eslint/template/click-events-have-key-events": "off",
46
+ "@angular-eslint/template/conditional-complexity": [
47
+ "error",
48
+ // Same as ESLint sonarjs/cognitive-complexity
49
+ {
50
+ "maxComplexity": 20
51
+ }
52
+ ],
53
+ "@angular-eslint/template/cyclomatic-complexity": [
54
+ "error",
55
+ // Same as ESLint complexity
56
+ {
57
+ "maxComplexity": 20
58
+ }
59
+ ],
19
60
  "@angular-eslint/template/eqeqeq": [
20
61
  "error",
21
62
  {
22
- "allowNullOrUndefined": true,
23
- },
63
+ "allowNullOrUndefined": true
64
+ }
24
65
  ],
25
- },
26
- },
27
- {
28
- files: ["*.ts"],
29
- plugins: ["rxjs-angular"],
30
- extends: [
66
+ "@angular-eslint/template/i18n": [
67
+ // Note: 'warn' because this adds a lot of complexity not all projects may want
68
+ // TODO: don't want the autofixer
69
+ "off",
70
+ {
71
+ // TODO: doesn't work for text elements. Raise the issue on github
72
+ "boundTextAllowedPattern": "EmPassion",
73
+ "ignoreTags": [
74
+ "meta",
75
+ "link",
76
+ "title",
77
+ "mat-icon"
78
+ ],
79
+ "ignoreAttributes": [
80
+ ...baseIgnoreAttributes,
81
+ // TODO: ask for those to be added in the library
82
+ "role",
83
+ "mat-form-field[appearance]",
84
+ "matTooltipPosition",
85
+ "input[autocomplete]",
86
+ "input[accept]",
87
+ "panelClass",
88
+ "cdkColumnDef"
89
+ ]
90
+ }
91
+ ],
92
+ "@angular-eslint/template/use-track-by-function": "error"
93
+ }
94
+ }, {
95
+ "files": ["*.ts"],
96
+ "plugins": ["rxjs-angular"],
97
+ "extends": [
31
98
  "./rxjs",
32
99
  "./typescript",
33
- "plugin:@angular-eslint/recommended",
34
- "plugin:@angular-eslint/template/process-inline-templates",
100
+ "plugin:@angular-eslint/all",
101
+ "plugin:@angular-eslint/template/process-inline-templates"
35
102
  ],
36
- parserOptions: {
103
+ "parserOptions": {
37
104
  "project": [
38
105
  "tsconfig.json",
39
106
  "tsconfig.app.json",
40
107
  "tsconfig.spec.json",
41
- "e2e/tsconfig.json",
108
+ "e2e/tsconfig.json"
42
109
  ],
43
- "createDefaultProgram": true,
110
+ "createDefaultProgram": true
44
111
  },
45
- rules: {
112
+ "rules": {
46
113
  // rxjs-angular rules
47
114
  "rxjs/no-finnish": "error",
48
115
  "rxjs-angular/prefer-async-pipe": "off",
@@ -50,67 +117,73 @@ module.exports = {
50
117
  // See: https://github.com/cartant/eslint-plugin-rxjs-angular/issues/1
51
118
  // "rxjs-angular/prefer-composition": "error",
52
119
  "rxjs-angular/prefer-takeuntil": "warn",
53
- // Angular-eslint overrides
120
+ // Angular-eslint overrides (https://github.com/angular-eslint/angular-eslint/tree/master/packages/eslint-plugin/docs/rules)
54
121
  "@angular-eslint/component-class-suffix": [
55
122
  "error",
56
123
  {
57
- "suffixes": ["Component", "Dialog"],
58
- },
124
+ "suffixes": ["Component", "Dialog"]
125
+ }
59
126
  ],
60
127
  "@angular-eslint/component-selector": [
61
128
  "error",
62
129
  {
63
130
  "type": "element",
64
- "prefix": "app",
65
- "style": "kebab-case",
66
- },
131
+ "style": "kebab-case"
132
+ }
67
133
  ],
68
134
  "@angular-eslint/directive-selector": [
69
135
  "error",
70
136
  {
71
137
  "type": "attribute",
72
- "prefix": "app",
73
- "style": "camelCase",
74
- },
138
+ "style": "camelCase"
139
+ }
75
140
  ],
76
- "@angular-eslint/no-empty-lifecycle-method": "error",
77
- "@angular-eslint/use-lifecycle-interface": "error",
141
+ "@angular-eslint/prefer-on-push-component-change-detection": "off",
142
+ // TODO: raise issue on github. Shouldn't warn for abstract classes
143
+ "@angular-eslint/use-component-selector": "warn",
78
144
  // Custom rules and @typescript-eslint/all overrides (https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/all.ts)
79
- "@typescript-eslint/consistent-type-definitions": [
80
- "error",
81
- "interface",
82
- ],
145
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
83
146
  // Angular needs more than just type information for dependency injection
84
147
  "@typescript-eslint/consistent-type-imports": [
85
148
  "error",
86
149
  {
87
- "prefer": "no-type-imports",
88
- },
150
+ "prefer": "no-type-imports"
151
+ }
89
152
  ],
90
153
  // Works with settings.json > "typescript.format.semicolons": "insert"
91
154
  "@typescript-eslint/member-delimiter-style": [
92
155
  "error",
93
156
  {
94
157
  "singleline": {
95
- "requireLast": true,
96
- },
97
- },
158
+ "requireLast": true
159
+ }
160
+ }
98
161
  ],
99
- "@typescript-eslint/semi": [
162
+ // From https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin/src/configs/recommended--extra.json
163
+ "@typescript-eslint/member-ordering": [
100
164
  "error",
101
- "always",
165
+ {
166
+ "default": [
167
+ "static-field",
168
+ "instance-field",
169
+ "static-method",
170
+ "instance-method"
171
+ ]
172
+ }
102
173
  ],
174
+ "@typescript-eslint/semi": ["error", "always"],
103
175
  // Angular directives can lead to empty classes
104
176
  "@typescript-eslint/no-extraneous-class": [
105
177
  "error",
106
178
  {
107
- "allowEmpty": true,
108
- },
179
+ "allowEmpty": true
180
+ }
109
181
  ],
110
182
  // Incompatible with Angular's dependecy injection
111
183
  "@typescript-eslint/no-invalid-this": "off",
112
184
  // Redundant with Angular's dependecy injection
113
185
  "@typescript-eslint/no-parameter-properties": "off",
186
+ "@typescript-eslint/parameter-properties": "off",
114
187
  // Angular directives can lead to `const myFunc = this.service.func`
115
188
  "@typescript-eslint/unbound-method": "off",
116
189
  // Allow class because of "classList"
@@ -119,45 +192,45 @@ module.exports = {
119
192
  {
120
193
  "disallowedPrefixes": [
121
194
  "for",
122
- "of",
123
- ],
124
- },
195
+ "of"
196
+ ]
197
+ }
125
198
  ],
126
199
  // Angular is ESM
127
200
  "unicorn/prefer-module": "error",
128
201
  "unicorn/prevent-abbreviations": [
129
202
  "error",
130
- preventAbbreviationsConfig,
203
+ preventAbbreviationsConfig
131
204
  ],
132
205
  "no-restricted-syntax": [
133
206
  "error",
134
207
  {
135
208
  "selector": "ClassDeclaration:has(Decorator :matches([name=\"Component\"], [name=\"Injectable\"])) :matches(PropertyDefinition[key.name=\"intercept\"], PropertyDefinition[key.name=\"ngOnChanges\"], PropertyDefinition[key.name=\"ngOnInit\"], PropertyDefinition[key.name=\"ngDoCheck\"], PropertyDefinition[key.name=\"ngAfterContentInit\"], PropertyDefinition[key.name=\"ngAfterContentChecked\"], PropertyDefinition[key.name=\"ngAfterViewInit\"], PropertyDefinition[key.name=\"ngAfterViewChecked\"], PropertyDefinition[key.name=\"ngOnDestroy\"]) > ArrowFunctionExpression",
136
- "message": "Angular hooks need to be functions defined on the prototype: https://github.com/angular/angular/issues/7270#issuecomment-201137617",
209
+ "message": "Angular hooks need to be functions defined on the prototype: https://github.com/angular/angular/issues/7270#issuecomment-201137617"
137
210
  },
138
- ],
139
- },
140
- },
141
- {
142
- "files": [
143
- "*.js",
144
- ],
145
- "extends": [
146
- "./node-js",
147
- ],
148
- },
149
- {
150
- "files": [
151
- "polyfills.ts",
152
- ],
211
+ {
212
+ "selector": "ImportDeclaration[source.value=/\\.\\.\\u002F?$/]",
213
+ "message": "Don't use imports that ends in \"..\" or \"../\""
214
+ },
215
+ // From https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin/src/configs/recommended--extra.json
216
+ {
217
+ "selector": "CallExpression[callee.object.name=\"console\"][callee.property.name=/^(debug|info|time|timeEnd|trace)$/]",
218
+ "message": "Unexpected property on console object was called"
219
+ }
220
+ ]
221
+ }
222
+ }, {
223
+ "files": ["*.js"],
224
+ "extends": ["./node-js"]
225
+ }, {
226
+ "files": ["polyfills.ts"],
153
227
  "rules": {
154
- "simple-import-sort/imports": "off",
155
- },
156
- },
157
- {
228
+ "simple-import-sort/imports": "off"
229
+ }
230
+ }, {
158
231
  // See no-restricted-syntax
159
- files: ["*[.-]component.ts", "*[.-]interceptor.ts"],
160
- rules: {
232
+ "files": ["*[.-]component.ts", "*[.-]interceptor.ts"],
233
+ "rules": {
161
234
  // Angular hooks should be named functions
162
235
  // https://github.com/mojohaus/extra-enforcer-rules/issues/186
163
236
  "extra-rules/potential-point-free": "warn",
@@ -166,34 +239,32 @@ module.exports = {
166
239
  {
167
240
  ...preferArrowFunctionsConfig,
168
241
  // https://github.com/TristonJ/eslint-plugin-prefer-arrow/issues/17
169
- "classPropertiesAllowed": false,
170
- },
171
- ],
172
- },
173
- },
174
- {
175
- files: ["*.e2e-spec.ts"],
176
- rules: {
242
+ "classPropertiesAllowed": false
243
+ }
244
+ ]
245
+ }
246
+ }, {
247
+ "files": ["*.e2e-spec.ts"],
248
+ "rules": {
177
249
  "unicorn/prevent-abbreviations": [
178
250
  "off",
179
- end2endPreventAbbreviationsConfig,
180
- ],
181
- },
182
- },
183
- {
184
- files: [
251
+ end2endPreventAbbreviationsConfig
252
+ ]
253
+ }
254
+ }, {
255
+ "files": [
185
256
  "*.js",
186
257
  "*.ts",
187
- "*.html",
258
+ "*.html"
188
259
  ],
189
- rules: {
260
+ "rules": {
190
261
  "unicorn/filename-case": [
191
262
  "error",
192
263
  {
193
- "case": "kebabCase",
194
- },
195
- ],
196
- },
197
- },
198
- ],
264
+ "case": "kebabCase"
265
+ }
266
+ ]
267
+ }
268
+ }
269
+ ]
199
270
  }
package/index.js CHANGED
@@ -1,8 +1,6 @@
1
- "use strict"
2
-
3
1
  module.exports = {
4
- extends: [
2
+ "extends": [
5
3
  "./javascript",
6
- "./typescript",
7
- ],
4
+ "./typescript"
5
+ ]
8
6
  }