@stride.it/appoint-lint-governance 0.1.21 → 0.1.23

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/dist/index.js CHANGED
@@ -2,41 +2,42 @@
2
2
  import tseslint from "typescript-eslint";
3
3
  function typescriptBase(options = {}) {
4
4
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
5
- return tseslint.config({
6
- files,
7
- plugins: {
8
- "@typescript-eslint": tseslint.plugin
9
- },
10
- languageOptions: {
11
- parser: tseslint.parser,
12
- parserOptions: {
13
- ecmaVersion: "latest",
14
- sourceType: "module"
5
+ return [
6
+ {
7
+ files,
8
+ plugins: {
9
+ "@typescript-eslint": tseslint.plugin
10
+ },
11
+ languageOptions: {
12
+ parser: tseslint.parser,
13
+ parserOptions: {
14
+ ecmaVersion: "latest",
15
+ sourceType: "module"
16
+ }
17
+ },
18
+ rules: {
19
+ "@typescript-eslint/consistent-type-imports": "error",
20
+ "@typescript-eslint/no-unused-vars": "error",
21
+ "@typescript-eslint/no-shadow": "error",
22
+ "@typescript-eslint/ban-ts-comment": "error",
23
+ "@typescript-eslint/no-explicit-any": "warn",
24
+ "@typescript-eslint/no-inferrable-types": "error",
25
+ "no-undef": "off",
26
+ "no-unused-vars": "off",
27
+ "no-var": "error",
28
+ "prefer-const": "error",
29
+ eqeqeq: ["error", "always", { null: "ignore" }],
30
+ "no-implicit-coercion": "error"
15
31
  }
16
- },
17
- rules: {
18
- "@typescript-eslint/consistent-type-imports": "error",
19
- "@typescript-eslint/no-unused-vars": "error",
20
- "@typescript-eslint/no-shadow": "error",
21
- "@typescript-eslint/ban-ts-comment": "error",
22
- "@typescript-eslint/no-explicit-any": "warn",
23
- "@typescript-eslint/no-inferrable-types": "error",
24
- "no-undef": "off",
25
- "no-unused-vars": "off",
26
- "no-var": "error",
27
- "prefer-const": "error",
28
- eqeqeq: ["error", "always", { null: "ignore" }],
29
- "no-implicit-coercion": "error"
30
32
  }
31
- });
33
+ ];
32
34
  }
33
35
 
34
36
  // src/configs/typescript/conventions.ts
35
37
  import importPlugin from "eslint-plugin-import";
36
- import tseslint2 from "typescript-eslint";
37
38
  function typescriptConventions(options = {}) {
38
39
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
39
- return tseslint2.config(
40
+ return [
40
41
  {
41
42
  files,
42
43
  plugins: {
@@ -47,7 +48,6 @@ function typescriptConventions(options = {}) {
47
48
  "import/no-default-export": "error",
48
49
  "@typescript-eslint/consistent-type-definitions": ["error", "type"],
49
50
  "@typescript-eslint/consistent-type-imports": "error",
50
- "@typescript-eslint/consistent-type-exports": "error",
51
51
  "prefer-arrow-callback": "error"
52
52
  }
53
53
  },
@@ -56,75 +56,95 @@ function typescriptConventions(options = {}) {
56
56
  files: [
57
57
  "**/*.config.{js,mjs,ts}",
58
58
  "**/app/**/{page,layout,template,not-found,global-error,loading,error}.tsx",
59
- "**/*.stories.tsx"
59
+ "**/*.stories.tsx",
60
+ "**/*.d.ts"
60
61
  ],
61
62
  rules: {
62
63
  "import/no-default-export": "off"
63
64
  }
64
65
  }
65
- );
66
+ ];
66
67
  }
67
68
 
68
69
  // src/configs/typescript/docs.ts
69
70
  import comments from "@eslint-community/eslint-plugin-eslint-comments";
70
71
  import jsdoc from "eslint-plugin-jsdoc";
71
- import tseslint3 from "typescript-eslint";
72
72
  function typescriptDocs(options = {}) {
73
73
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
74
- return tseslint3.config({
75
- files,
76
- plugins: {
77
- jsdoc,
78
- "eslint-comments": comments
79
- },
80
- rules: {
81
- "eslint-comments/no-unused-disable": "error",
82
- "eslint-comments/require-description": "error",
83
- "eslint-comments/disable-enable-pair": "error",
84
- "jsdoc/check-alignment": "error",
85
- "jsdoc/require-param": "error",
86
- "jsdoc/require-returns": "error"
74
+ return [
75
+ {
76
+ files,
77
+ plugins: {
78
+ jsdoc,
79
+ "eslint-comments": comments
80
+ },
81
+ rules: {
82
+ "eslint-comments/no-unused-disable": "error",
83
+ "eslint-comments/no-unlimited-disable": "error",
84
+ "eslint-comments/require-description": "error",
85
+ "eslint-comments/disable-enable-pair": "error",
86
+ "jsdoc/check-alignment": "error",
87
+ "jsdoc/require-param": "error",
88
+ "jsdoc/require-returns": "error"
89
+ }
87
90
  }
88
- });
91
+ ];
89
92
  }
90
93
 
91
94
  // src/configs/typescript/imports.ts
92
95
  import importPlugin2 from "eslint-plugin-import";
93
96
  import simpleImportSort from "eslint-plugin-simple-import-sort";
94
- import tseslint4 from "typescript-eslint";
97
+ var IMPORTS_RULES = {
98
+ "import/no-duplicates": "error",
99
+ "import/no-cycle": "error",
100
+ "import/no-mutable-exports": "error",
101
+ "import/first": "error",
102
+ "import/newline-after-import": "error",
103
+ "import/no-extraneous-dependencies": [
104
+ "error",
105
+ {
106
+ devDependencies: [
107
+ "**/*.test.ts",
108
+ "**/*.spec.ts",
109
+ "test/**",
110
+ "tests/**",
111
+ "**/*.config.{js,ts,mjs}",
112
+ "**/*.stories.tsx",
113
+ "scripts/**"
114
+ ],
115
+ optionalDependencies: false,
116
+ peerDependencies: false
117
+ }
118
+ ],
119
+ "simple-import-sort/imports": "error",
120
+ "simple-import-sort/exports": "error",
121
+ "import/no-deprecated": "error",
122
+ "no-restricted-imports": "off"
123
+ };
95
124
  function typescriptImports(options = {}) {
96
125
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
97
- return tseslint4.config({
98
- files,
99
- plugins: {
100
- import: importPlugin2,
101
- "simple-import-sort": simpleImportSort
102
- },
103
- settings: {
104
- "import/parsers": {
105
- "@typescript-eslint/parser": [".ts", ".tsx", ".mts", ".cts"]
126
+ return [
127
+ {
128
+ files,
129
+ plugins: {
130
+ import: importPlugin2,
131
+ "simple-import-sort": simpleImportSort
106
132
  },
107
- "import/resolver": {
108
- typescript: {
109
- alwaysTryTypes: true,
110
- project: ["tsconfig.json", "*/tsconfig.json"]
133
+ settings: {
134
+ "import/parsers": {
135
+ "@typescript-eslint/parser": [".ts", ".tsx", ".mts", ".cts"]
111
136
  },
112
- node: true
113
- }
114
- },
115
- rules: {
116
- // Import Correctness
117
- "import/no-duplicates": "error",
118
- "import/no-cycle": "error",
119
- "import/no-mutable-exports": "error",
120
- "import/first": "error",
121
- "import/newline-after-import": "error",
122
- "import/no-extraneous-dependencies": "error",
123
- // Sorting
124
- "simple-import-sort/imports": "error",
125
- "simple-import-sort/exports": "error"
137
+ "import/resolver": {
138
+ typescript: {
139
+ alwaysTryTypes: true,
140
+ project: ["tsconfig.json", "*/tsconfig.json"]
141
+ },
142
+ node: true
143
+ }
144
+ },
145
+ rules: IMPORTS_RULES
126
146
  }
127
- });
147
+ ];
128
148
  }
129
149
 
130
150
  // src/configs/typescript/minimal.ts
@@ -132,174 +152,210 @@ function typescriptMinimal(options = {}) {
132
152
  return typescriptBase(options);
133
153
  }
134
154
 
155
+ // src/configs/typescript/naming-env.ts
156
+ import unicorn from "eslint-plugin-unicorn";
157
+ var NAMING_RULES = {
158
+ "unicorn/filename-case": [
159
+ "error",
160
+ {
161
+ cases: {
162
+ kebabCase: true,
163
+ pascalCase: true
164
+ },
165
+ ignore: ["NEXT_", "README", "CHANGELOG", "LICENSE", "Dockerfile", "^_"]
166
+ }
167
+ ],
168
+ "no-restricted-globals": ["error", "event", "fdescribe"]
169
+ };
170
+ function typescriptNamingEnv(options = {}) {
171
+ const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
172
+ return [
173
+ {
174
+ files,
175
+ plugins: {
176
+ unicorn
177
+ },
178
+ rules: NAMING_RULES
179
+ }
180
+ ];
181
+ }
182
+
135
183
  // src/configs/typescript/prettier.ts
136
184
  import eslintConfigPrettier from "eslint-config-prettier";
137
- import tseslint5 from "typescript-eslint";
138
185
  function typescriptPrettierInterop(options = {}) {
139
186
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
140
- return tseslint5.config({
141
- files,
142
- rules: {
143
- ...eslintConfigPrettier.rules
187
+ return [
188
+ {
189
+ files,
190
+ rules: {
191
+ ...eslintConfigPrettier.rules
192
+ }
144
193
  }
145
- });
194
+ ];
146
195
  }
147
196
 
148
197
  // src/configs/typescript/recommended.ts
149
- import tseslint10 from "typescript-eslint";
198
+ import tseslint3 from "typescript-eslint";
150
199
 
151
200
  // src/configs/typescript/quality.ts
152
201
  import sonarjs from "eslint-plugin-sonarjs";
153
- import unicorn from "eslint-plugin-unicorn";
154
- import tseslint6 from "typescript-eslint";
202
+ import unicorn2 from "eslint-plugin-unicorn";
203
+ var UNICORN_ABBREVIATIONS = {
204
+ allowList: {
205
+ Props: true,
206
+ props: true,
207
+ Ref: true,
208
+ ref: true,
209
+ Src: true,
210
+ src: true,
211
+ Params: true,
212
+ params: true,
213
+ Env: true,
214
+ env: true,
215
+ Args: true,
216
+ args: true,
217
+ Docs: true,
218
+ docs: true,
219
+ arg: true,
220
+ err: true,
221
+ req: true,
222
+ res: true,
223
+ ctx: true,
224
+ val: true
225
+ }
226
+ };
155
227
  function typescriptQuality(options = {}) {
156
228
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
157
- return tseslint6.config({
158
- files,
159
- plugins: {
160
- unicorn,
161
- sonarjs
162
- },
163
- rules: {
164
- // Unicorn
165
- "unicorn/prefer-node-protocol": "error",
166
- "unicorn/no-useless-undefined": "error",
167
- "unicorn/no-lonely-if": "error",
168
- "unicorn/prefer-optional-catch-binding": "error",
169
- "unicorn/prefer-string-replace-all": "error",
170
- "unicorn/prevent-abbreviations": [
171
- "warn",
172
- {
173
- allowList: {
174
- Props: true,
175
- props: true,
176
- Ref: true,
177
- ref: true,
178
- Src: true,
179
- src: true,
180
- Params: true,
181
- params: true,
182
- Env: true,
183
- env: true,
184
- Args: true,
185
- args: true,
186
- Docs: true,
187
- docs: true,
188
- arg: true,
189
- err: true,
190
- req: true,
191
- res: true,
192
- ctx: true,
193
- val: true
194
- }
195
- }
196
- ],
197
- // Best Practices
198
- "consistent-return": "error",
199
- // SonarJS
200
- "sonarjs/cognitive-complexity": ["error", 15],
201
- "sonarjs/no-identical-functions": "error",
202
- "sonarjs/no-duplicated-branches": "error",
203
- "sonarjs/no-redundant-boolean": "error",
204
- "sonarjs/no-inverted-boolean-check": "error"
229
+ return [
230
+ {
231
+ files,
232
+ plugins: {
233
+ unicorn: unicorn2,
234
+ sonarjs
235
+ },
236
+ rules: {
237
+ // Unicorn
238
+ "unicorn/prefer-node-protocol": "error",
239
+ "unicorn/no-useless-undefined": "error",
240
+ "unicorn/no-lonely-if": "error",
241
+ "unicorn/prefer-optional-catch-binding": "error",
242
+ "unicorn/prefer-string-replace-all": "error",
243
+ "unicorn/prevent-abbreviations": ["warn", UNICORN_ABBREVIATIONS],
244
+ // Best Practices
245
+ "consistent-return": "error",
246
+ "no-implicit-coercion": "error",
247
+ // SonarJS
248
+ "sonarjs/cognitive-complexity": ["error", 15],
249
+ "sonarjs/no-identical-functions": "error",
250
+ "sonarjs/no-duplicated-branches": "error",
251
+ "sonarjs/no-redundant-boolean": "error",
252
+ "sonarjs/no-inverted-boolean-check": "error"
253
+ }
205
254
  }
206
- });
255
+ ];
207
256
  }
208
257
 
209
258
  // src/configs/typescript/security.ts
210
259
  import regexpPlugin from "eslint-plugin-regexp";
211
260
  import securityPlugin from "eslint-plugin-security";
212
- import tseslint7 from "typescript-eslint";
213
261
  function typescriptSecurity(options = {}) {
214
262
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
215
- return tseslint7.config({
216
- files,
217
- plugins: {
218
- security: securityPlugin,
219
- regexp: regexpPlugin
220
- },
221
- rules: {
222
- // eslint-plugin-security
223
- "security/detect-object-injection": "error",
224
- "security/detect-unsafe-regex": "error",
225
- // eslint-plugin-regexp
226
- "regexp/no-super-linear-backtracking": "error",
227
- "regexp/no-useless-escape": "error",
228
- "regexp/no-empty-capturing-group": "error"
263
+ return [
264
+ {
265
+ files,
266
+ plugins: {
267
+ security: securityPlugin,
268
+ regexp: regexpPlugin
269
+ },
270
+ rules: {
271
+ // eslint-plugin-security
272
+ "security/detect-object-injection": "error",
273
+ "security/detect-unsafe-regex": "error",
274
+ // eslint-plugin-regexp
275
+ "regexp/no-super-linear-backtracking": "error",
276
+ "regexp/no-useless-escape": "error",
277
+ "regexp/no-empty-capturing-group": "error"
278
+ }
229
279
  }
230
- });
280
+ ];
231
281
  }
232
282
 
233
283
  // src/configs/typescript/size-complexity.ts
234
- import tseslint8 from "typescript-eslint";
235
284
  function typescriptSizeComplexity(options = {}) {
236
285
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
237
- return tseslint8.config({
238
- files,
239
- rules: {
240
- "max-lines": [
241
- "error",
242
- { max: 100, skipBlankLines: true, skipComments: true }
243
- ],
244
- "max-lines-per-function": [
245
- "error",
246
- { max: 50, skipBlankLines: true, skipComments: true }
247
- ],
248
- complexity: ["error", 15],
249
- "max-params": ["error", 3],
250
- "no-var": "error",
251
- "prefer-const": "warn"
286
+ return [
287
+ {
288
+ files,
289
+ rules: {
290
+ "max-lines": [
291
+ "error",
292
+ { max: 100, skipBlankLines: true, skipComments: true }
293
+ ],
294
+ "max-lines-per-function": [
295
+ "error",
296
+ { max: 50, skipBlankLines: true, skipComments: true }
297
+ ],
298
+ complexity: ["error", 15],
299
+ "max-params": ["error", 3],
300
+ "max-depth": ["error", 4],
301
+ "no-var": "error",
302
+ "prefer-const": "warn"
303
+ }
252
304
  }
253
- });
305
+ ];
254
306
  }
255
307
 
256
308
  // src/configs/typescript/type-aware.ts
257
- import tseslint9 from "typescript-eslint";
309
+ import tseslint2 from "typescript-eslint";
258
310
  function typescriptTypeAware(options = {}) {
259
311
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
260
- return tseslint9.config({
261
- files,
262
- plugins: {
263
- "@typescript-eslint": tseslint9.plugin
264
- },
265
- languageOptions: {
266
- parserOptions: {
267
- project: options.tsconfigPath ?? "./tsconfig.json",
268
- tsconfigRootDir: options.tsconfigRootDir
312
+ return [
313
+ {
314
+ files,
315
+ plugins: {
316
+ "@typescript-eslint": tseslint2.plugin
317
+ },
318
+ languageOptions: {
319
+ parserOptions: {
320
+ project: options.tsconfigPath ?? "./tsconfig.json",
321
+ tsconfigRootDir: options.tsconfigRootDir
322
+ }
323
+ },
324
+ rules: {
325
+ "@typescript-eslint/require-await": "error",
326
+ "@typescript-eslint/no-floating-promises": "error",
327
+ "@typescript-eslint/no-misused-promises": "error",
328
+ "@typescript-eslint/await-thenable": "error",
329
+ "@typescript-eslint/no-unnecessary-condition": "warn",
330
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
331
+ "@typescript-eslint/restrict-template-expressions": "error",
332
+ "@typescript-eslint/prefer-nullish-coalescing": "error",
333
+ "@typescript-eslint/prefer-optional-chain": "error",
334
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
335
+ "@typescript-eslint/no-deprecated": "error",
336
+ "@typescript-eslint/consistent-type-exports": "error"
269
337
  }
270
- },
271
- rules: {
272
- "@typescript-eslint/require-await": "error",
273
- "@typescript-eslint/no-floating-promises": "error",
274
- "@typescript-eslint/no-misused-promises": "error",
275
- "@typescript-eslint/await-thenable": "error",
276
- "@typescript-eslint/no-unnecessary-condition": "warn",
277
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
278
- "@typescript-eslint/restrict-template-expressions": "error",
279
- "@typescript-eslint/prefer-nullish-coalescing": "error",
280
- "@typescript-eslint/prefer-optional-chain": "error",
281
- "@typescript-eslint/switch-exhaustiveness-check": "error",
282
- "@typescript-eslint/no-deprecated": "error"
283
338
  }
284
- });
339
+ ];
285
340
  }
286
341
 
287
342
  // src/configs/typescript/recommended.ts
288
343
  function typescriptRecommended(options = {}) {
289
344
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
290
345
  const enableConventions = options.enableConventions ?? true;
291
- const upstreamConfigs = options.typeChecked ? tseslint10.configs.recommendedTypeChecked : tseslint10.configs.recommended;
346
+ const upstreamConfigs = options.typeChecked ? tseslint3.configs.recommendedTypeChecked : tseslint3.configs.recommended;
292
347
  const typeAwareConfig = options.typeChecked ? typescriptTypeAware({
293
348
  files,
294
349
  tsconfigPath: options.tsconfigPath,
295
350
  tsconfigRootDir: options.tsconfigRootDir
296
351
  }) : [];
297
352
  const conventionsConfig = enableConventions ? typescriptConventions({ files }) : [];
298
- return tseslint10.config(
353
+ return [
299
354
  ...typescriptBase({ files }),
300
355
  ...typescriptQuality({ files }),
301
356
  ...typescriptImports({ files }),
302
357
  ...typescriptSecurity({ files }),
358
+ ...typescriptNamingEnv({ files }),
303
359
  ...typescriptDocs({ files }),
304
360
  ...typescriptSizeComplexity({ files }),
305
361
  ...conventionsConfig,
@@ -308,7 +364,7 @@ function typescriptRecommended(options = {}) {
308
364
  ...config,
309
365
  files
310
366
  }))
311
- );
367
+ ];
312
368
  }
313
369
 
314
370
  // src/plugin/index.ts