@stride.it/appoint-lint-governance 0.1.22 → 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,90 +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": [
123
- "error",
124
- {
125
- devDependencies: [
126
- "**/*.test.ts",
127
- "**/*.spec.ts",
128
- "test/**",
129
- "tests/**",
130
- "**/*.config.{js,ts,mjs}",
131
- "**/*.stories.tsx",
132
- "scripts/**"
133
- ],
134
- optionalDependencies: false,
135
- peerDependencies: false
137
+ "import/resolver": {
138
+ typescript: {
139
+ alwaysTryTypes: true,
140
+ project: ["tsconfig.json", "*/tsconfig.json"]
141
+ },
142
+ node: true
136
143
  }
137
- ],
138
- // Sorting
139
- "simple-import-sort/imports": "error",
140
- "simple-import-sort/exports": "error"
144
+ },
145
+ rules: IMPORTS_RULES
141
146
  }
142
- });
147
+ ];
143
148
  }
144
149
 
145
150
  // src/configs/typescript/minimal.ts
@@ -147,174 +152,210 @@ function typescriptMinimal(options = {}) {
147
152
  return typescriptBase(options);
148
153
  }
149
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
+
150
183
  // src/configs/typescript/prettier.ts
151
184
  import eslintConfigPrettier from "eslint-config-prettier";
152
- import tseslint5 from "typescript-eslint";
153
185
  function typescriptPrettierInterop(options = {}) {
154
186
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
155
- return tseslint5.config({
156
- files,
157
- rules: {
158
- ...eslintConfigPrettier.rules
187
+ return [
188
+ {
189
+ files,
190
+ rules: {
191
+ ...eslintConfigPrettier.rules
192
+ }
159
193
  }
160
- });
194
+ ];
161
195
  }
162
196
 
163
197
  // src/configs/typescript/recommended.ts
164
- import tseslint10 from "typescript-eslint";
198
+ import tseslint3 from "typescript-eslint";
165
199
 
166
200
  // src/configs/typescript/quality.ts
167
201
  import sonarjs from "eslint-plugin-sonarjs";
168
- import unicorn from "eslint-plugin-unicorn";
169
- 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
+ };
170
227
  function typescriptQuality(options = {}) {
171
228
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
172
- return tseslint6.config({
173
- files,
174
- plugins: {
175
- unicorn,
176
- sonarjs
177
- },
178
- rules: {
179
- // Unicorn
180
- "unicorn/prefer-node-protocol": "error",
181
- "unicorn/no-useless-undefined": "error",
182
- "unicorn/no-lonely-if": "error",
183
- "unicorn/prefer-optional-catch-binding": "error",
184
- "unicorn/prefer-string-replace-all": "error",
185
- "unicorn/prevent-abbreviations": [
186
- "warn",
187
- {
188
- allowList: {
189
- Props: true,
190
- props: true,
191
- Ref: true,
192
- ref: true,
193
- Src: true,
194
- src: true,
195
- Params: true,
196
- params: true,
197
- Env: true,
198
- env: true,
199
- Args: true,
200
- args: true,
201
- Docs: true,
202
- docs: true,
203
- arg: true,
204
- err: true,
205
- req: true,
206
- res: true,
207
- ctx: true,
208
- val: true
209
- }
210
- }
211
- ],
212
- // Best Practices
213
- "consistent-return": "error",
214
- // SonarJS
215
- "sonarjs/cognitive-complexity": ["error", 15],
216
- "sonarjs/no-identical-functions": "error",
217
- "sonarjs/no-duplicated-branches": "error",
218
- "sonarjs/no-redundant-boolean": "error",
219
- "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
+ }
220
254
  }
221
- });
255
+ ];
222
256
  }
223
257
 
224
258
  // src/configs/typescript/security.ts
225
259
  import regexpPlugin from "eslint-plugin-regexp";
226
260
  import securityPlugin from "eslint-plugin-security";
227
- import tseslint7 from "typescript-eslint";
228
261
  function typescriptSecurity(options = {}) {
229
262
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
230
- return tseslint7.config({
231
- files,
232
- plugins: {
233
- security: securityPlugin,
234
- regexp: regexpPlugin
235
- },
236
- rules: {
237
- // eslint-plugin-security
238
- "security/detect-object-injection": "error",
239
- "security/detect-unsafe-regex": "error",
240
- // eslint-plugin-regexp
241
- "regexp/no-super-linear-backtracking": "error",
242
- "regexp/no-useless-escape": "error",
243
- "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
+ }
244
279
  }
245
- });
280
+ ];
246
281
  }
247
282
 
248
283
  // src/configs/typescript/size-complexity.ts
249
- import tseslint8 from "typescript-eslint";
250
284
  function typescriptSizeComplexity(options = {}) {
251
285
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
252
- return tseslint8.config({
253
- files,
254
- rules: {
255
- "max-lines": [
256
- "error",
257
- { max: 100, skipBlankLines: true, skipComments: true }
258
- ],
259
- "max-lines-per-function": [
260
- "error",
261
- { max: 50, skipBlankLines: true, skipComments: true }
262
- ],
263
- complexity: ["error", 15],
264
- "max-params": ["error", 3],
265
- "no-var": "error",
266
- "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
+ }
267
304
  }
268
- });
305
+ ];
269
306
  }
270
307
 
271
308
  // src/configs/typescript/type-aware.ts
272
- import tseslint9 from "typescript-eslint";
309
+ import tseslint2 from "typescript-eslint";
273
310
  function typescriptTypeAware(options = {}) {
274
311
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
275
- return tseslint9.config({
276
- files,
277
- plugins: {
278
- "@typescript-eslint": tseslint9.plugin
279
- },
280
- languageOptions: {
281
- parserOptions: {
282
- project: options.tsconfigPath ?? "./tsconfig.json",
283
- 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"
284
337
  }
285
- },
286
- rules: {
287
- "@typescript-eslint/require-await": "error",
288
- "@typescript-eslint/no-floating-promises": "error",
289
- "@typescript-eslint/no-misused-promises": "error",
290
- "@typescript-eslint/await-thenable": "error",
291
- "@typescript-eslint/no-unnecessary-condition": "warn",
292
- "@typescript-eslint/no-unnecessary-type-assertion": "error",
293
- "@typescript-eslint/restrict-template-expressions": "error",
294
- "@typescript-eslint/prefer-nullish-coalescing": "error",
295
- "@typescript-eslint/prefer-optional-chain": "error",
296
- "@typescript-eslint/switch-exhaustiveness-check": "error",
297
- "@typescript-eslint/no-deprecated": "error"
298
338
  }
299
- });
339
+ ];
300
340
  }
301
341
 
302
342
  // src/configs/typescript/recommended.ts
303
343
  function typescriptRecommended(options = {}) {
304
344
  const files = options.files ?? ["**/*.{ts,tsx,mts,cts}"];
305
345
  const enableConventions = options.enableConventions ?? true;
306
- const upstreamConfigs = options.typeChecked ? tseslint10.configs.recommendedTypeChecked : tseslint10.configs.recommended;
346
+ const upstreamConfigs = options.typeChecked ? tseslint3.configs.recommendedTypeChecked : tseslint3.configs.recommended;
307
347
  const typeAwareConfig = options.typeChecked ? typescriptTypeAware({
308
348
  files,
309
349
  tsconfigPath: options.tsconfigPath,
310
350
  tsconfigRootDir: options.tsconfigRootDir
311
351
  }) : [];
312
352
  const conventionsConfig = enableConventions ? typescriptConventions({ files }) : [];
313
- return tseslint10.config(
353
+ return [
314
354
  ...typescriptBase({ files }),
315
355
  ...typescriptQuality({ files }),
316
356
  ...typescriptImports({ files }),
317
357
  ...typescriptSecurity({ files }),
358
+ ...typescriptNamingEnv({ files }),
318
359
  ...typescriptDocs({ files }),
319
360
  ...typescriptSizeComplexity({ files }),
320
361
  ...conventionsConfig,
@@ -323,7 +364,7 @@ function typescriptRecommended(options = {}) {
323
364
  ...config,
324
365
  files
325
366
  }))
326
- );
367
+ ];
327
368
  }
328
369
 
329
370
  // src/plugin/index.ts