@odg/eslint-config 2.0.3 → 3.0.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/index.mjs ADDED
@@ -0,0 +1,463 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ import * as toml from "eslint-plugin-toml";
4
+
5
+ import stylistic from "@stylistic/eslint-plugin";
6
+ import antfu from "eslint-plugin-antfu";
7
+ import arrayFunc from "eslint-plugin-array-func";
8
+ import fileProgress from "eslint-plugin-file-progress";
9
+ import unicorn from "eslint-plugin-unicorn";
10
+ import globals from "globals";
11
+ import * as tomlParser from "toml-eslint-parser";
12
+ import * as yamlParser from "yaml-eslint-parser";
13
+
14
+ import anyBase from "./rules/any/base.mjs";
15
+ import globalBase from "./rules/global/base.mjs";
16
+ import globalErrors from "./rules/global/errors.mjs";
17
+ import globalPossibleErrors from "./rules/global/possible-errors.mjs";
18
+ import globalSecurity from "./rules/global/security.mjs";
19
+ import iniBase from "./rules/ini/base.mjs";
20
+ import javascriptBestPractices from "./rules/javascript/best-practices.mjs";
21
+ import javascriptErrors from "./rules/javascript/errors.mjs";
22
+ import javascriptJsDocumentation from "./rules/javascript/js-documentation.mjs";
23
+ import javascriptPerformance from "./rules/javascript/performance.mjs";
24
+ import jsonBase from "./rules/json/base.mjs";
25
+ import typescriptBestPractices from "./rules/typescript/best-practices.mjs";
26
+ import typescriptErrors from "./rules/typescript/errors.mjs";
27
+ import typescriptPossibleErrors from "./rules/typescript/possible-errors.mjs";
28
+ import typescriptSecurity from "./rules/typescript/security.mjs";
29
+ import typescriptTests from "./rules/typescript/tests.mjs";
30
+ import yamlBase from "./rules/yaml/base.mjs";
31
+ import yamlGithub from "./rules/yaml/github.mjs";
32
+
33
+ const require = createRequire(import.meta.url);
34
+
35
+ // Import plugins (most are CommonJS)
36
+
37
+ const typescriptParser = require("@typescript-eslint/parser");
38
+
39
+ const odgPlugin = require("@odg/eslint-plugin");
40
+ const typescriptEslint = require("@typescript-eslint/eslint-plugin");
41
+ const anyParser = require("any-eslint-parser");
42
+ const betterMaxParams = require("eslint-plugin-better-max-params");
43
+ const filenames = require("eslint-plugin-filenames");
44
+ const html = require("eslint-plugin-html");
45
+ const importPlugin = require("eslint-plugin-import");
46
+ const jsdoc = require("eslint-plugin-jsdoc");
47
+ const jsonSchemaValidator = require("eslint-plugin-json-schema-validator");
48
+ const jsonc = require("eslint-plugin-jsonc");
49
+ const pluginN = require("eslint-plugin-n");
50
+ const noConstructorBind = require("eslint-plugin-no-constructor-bind");
51
+ const phpMarkup = require("eslint-plugin-php-markup");
52
+ const promise = require("eslint-plugin-promise");
53
+ const regex = require("eslint-plugin-regex");
54
+ const regexp = require("eslint-plugin-regexp");
55
+ const security = require("eslint-plugin-security");
56
+ const sonarjs = require("eslint-plugin-sonarjs");
57
+ const sortClassMembers = require("eslint-plugin-sort-class-members");
58
+ const yml = require("eslint-plugin-yml");
59
+ const espree = require("espree");
60
+ const jsoncParser = require("jsonc-eslint-parser");
61
+
62
+ export default [
63
+
64
+ // Base configuration
65
+ {
66
+ ignores: [
67
+ "!.*",
68
+ ".git/",
69
+ "node_modules/",
70
+ "bower_components/",
71
+ "jspm_packages/",
72
+ ".npm/",
73
+ "vendor/",
74
+ "lib-cov/",
75
+ "coverage/",
76
+ ".nyc_output/",
77
+ ".cache/",
78
+ "build/",
79
+ "dist/",
80
+ "tmp/",
81
+ "**/*.min.*",
82
+ "**/*.png",
83
+ "package-lock.json",
84
+ "yarn.lock",
85
+ ],
86
+ },
87
+
88
+ // Global configuration
89
+ {
90
+ languageOptions: {
91
+ parser: anyParser,
92
+ globals: {
93
+ ...globals.node,
94
+ ...globals.browser,
95
+ },
96
+ parserOptions: {
97
+ sourceType: "module",
98
+ ecmaVersion: 2022,
99
+ },
100
+ },
101
+ plugins: {
102
+ "progress": fileProgress,
103
+ "import": importPlugin,
104
+ "@odg": odgPlugin,
105
+ "@stylistic": stylistic,
106
+ "n": pluginN,
107
+ regexp,
108
+ regex,
109
+ sonarjs,
110
+ security,
111
+ unicorn,
112
+ },
113
+ settings: {
114
+ "html/report-bad-indent": "error",
115
+ "html/indent": "+4",
116
+ "import/docstyle": [ "jsdoc", "tomdoc" ],
117
+ "import/resolver": {
118
+ node: {
119
+ extensions: [ ".mjs", ".js", ".jsx", ".json", ".ts", ".tsx", ".d.ts" ],
120
+ },
121
+ },
122
+ "import/external-module-folders": [ "@types" ],
123
+ "import/extensions": [ ".js", ".mjs", ".jsx" ],
124
+ "import/core-modules": [],
125
+ "import/ignore": [ "node_modules", String.raw`\.(coffee|scss|css|less|hbs|svg|json)$` ],
126
+ "progress": {
127
+ hide: false, // Use this to hide the progress message, can be useful in CI
128
+ hideFileName: false, // Use this to hide the file name, would simply show "Linting..."
129
+ successMessage: "Lint done...",
130
+ },
131
+ },
132
+ rules: {
133
+ ...globalBase.rules,
134
+ ...globalErrors.rules,
135
+ ...globalPossibleErrors.rules,
136
+ ...globalSecurity.rules,
137
+ "progress/activate": 1,
138
+ },
139
+ },
140
+
141
+ // JavaScript/TypeScript files
142
+ {
143
+ files: [ "**/*.js", "**/*.jsx", "**/*.mjs", "**/*.cjs", "**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts" ],
144
+ languageOptions: {
145
+ parser: espree,
146
+ parserOptions: {
147
+ sourceType: "module",
148
+ ecmaVersion: 2022,
149
+ },
150
+ },
151
+ plugins: {
152
+ "import": importPlugin,
153
+ "n": pluginN,
154
+ "array-func": arrayFunc,
155
+ "no-constructor-bind": noConstructorBind,
156
+ "sort-class-members": sortClassMembers,
157
+ "better-max-params": betterMaxParams,
158
+ jsdoc,
159
+ promise,
160
+ regexp,
161
+ filenames,
162
+ security,
163
+ unicorn,
164
+ html,
165
+ regex,
166
+ sonarjs,
167
+ antfu,
168
+ },
169
+ rules: {
170
+ ...javascriptBestPractices.rules,
171
+ ...javascriptErrors.rules,
172
+ ...javascriptJsDocumentation.rules,
173
+ ...javascriptPerformance.rules,
174
+ },
175
+ },
176
+
177
+ // TypeScript files
178
+ {
179
+ files: [ "**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts" ],
180
+ languageOptions: {
181
+ parser: typescriptParser,
182
+ parserOptions: {
183
+ ecmaFeatures: {
184
+ jsx: true,
185
+ },
186
+ warnOnUnsupportedTypeScriptVersion: false,
187
+ ecmaVersion: 2022,
188
+ sourceType: "module",
189
+ project: [ "tsconfig.json", "@odg/tsconfig/tsconfig.json" ],
190
+ },
191
+ globals: {
192
+ ...globals.node,
193
+ ...globals.browser,
194
+ },
195
+ },
196
+ plugins: {
197
+ "@typescript-eslint": typescriptEslint,
198
+ "import": importPlugin,
199
+ "sort-class-members": sortClassMembers,
200
+ jsdoc,
201
+ promise,
202
+ regexp,
203
+ filenames,
204
+ },
205
+ settings: {
206
+ "import/extensions": [ ".mjs", ".js", ".jsx", ".json", ".ts", ".tsx", ".d.ts" ],
207
+ "import/external-module-folders": [ "node_modules", "node_modules/@types" ],
208
+ "import/parsers": {
209
+ "@typescript-eslint/parser": [ ".ts", ".tsx" ],
210
+ },
211
+ "import/resolver": {
212
+ typescript: {
213
+ project: [ "tsconfig.json" ],
214
+ },
215
+ node: {
216
+ extensions: [ ".mjs", ".js", ".jsx", ".json", ".ts", ".tsx", ".d.ts" ],
217
+ },
218
+ },
219
+ },
220
+ rules: {
221
+ ...typescriptBestPractices.rules,
222
+ ...typescriptErrors.rules,
223
+ ...typescriptSecurity.rules,
224
+ ...typescriptPossibleErrors.rules,
225
+ },
226
+ },
227
+
228
+ // TSX files
229
+ {
230
+ files: [ "**/*.tsx" ],
231
+ rules: {
232
+ "import/no-anonymous-default-export": [ "off" ],
233
+ "@typescript-eslint/naming-convention": [
234
+ "error",
235
+ {
236
+ selector: [ "function" ],
237
+ format: [ "PascalCase", "camelCase" ],
238
+ leadingUnderscore: "allowSingleOrDouble",
239
+ trailingUnderscore: "allow",
240
+ filter: {
241
+ regex: "[- ]",
242
+ match: false,
243
+ },
244
+ },
245
+ {
246
+ selector: [
247
+ "variable",
248
+ "function",
249
+ "parameterProperty",
250
+ "classMethod",
251
+ "objectLiteralMethod",
252
+ "typeMethod",
253
+ "accessor",
254
+ ],
255
+ format: [ "strictCamelCase", "camelCase" ],
256
+ leadingUnderscore: "allowSingleOrDouble",
257
+ trailingUnderscore: "allow",
258
+ filter: {
259
+ regex: "[- ]",
260
+ match: false,
261
+ },
262
+ },
263
+ {
264
+ selector: "classProperty",
265
+ format: [ "strictCamelCase", "camelCase", "UPPER_CASE" ],
266
+ },
267
+ {
268
+ selector: "typeLike",
269
+ format: [ "PascalCase", "camelCase" ],
270
+ },
271
+ {
272
+ selector: "variable",
273
+ types: [ "boolean" ],
274
+ format: [ "StrictPascalCase" ],
275
+ prefix: [ "is", "has", "can", "should", "will", "did", "does", "are", "do" ],
276
+ },
277
+ {
278
+ selector: "interface",
279
+ format: [ "PascalCase" ],
280
+ },
281
+ {
282
+ selector: "typeParameter",
283
+ filter: /^T$|^[A-Z][A-Za-z]+$/.source,
284
+ format: [ "StrictPascalCase" ],
285
+ },
286
+ {
287
+ selector: [ "classProperty", "objectLiteralProperty" ],
288
+ format: null,
289
+ modifiers: [ "requiresQuotes" ],
290
+ },
291
+ ],
292
+ },
293
+ },
294
+
295
+ // Config files
296
+ {
297
+ files: [ "./.*", "./*.*", ".github/**", ".vscode/**" ],
298
+ plugins: {
299
+ "json-schema-validator": jsonSchemaValidator,
300
+ },
301
+ rules: jsonSchemaValidator.configs?.recommended?.rules || {},
302
+ },
303
+ {
304
+ files: [
305
+ "**/*.config.ts",
306
+ "**/*.config.mts",
307
+ "**/*.config.js",
308
+ "**/*.config.mjs",
309
+ "**/index.mjs",
310
+ "**/index.mts",
311
+ ],
312
+ rules: {
313
+ "import/no-anonymous-default-export": [ "off" ],
314
+ "filenames/match-exported": [ "off" ],
315
+ "import/no-extraneous-dependencies": [ "off" ],
316
+ },
317
+ },
318
+
319
+ // JSON files
320
+ {
321
+ files: [ "**/*.json", "**/*.json5", "**/*.jsonc", ".eslintrc", "**/*.code-*" ],
322
+ languageOptions: {
323
+ parser: jsoncParser,
324
+ },
325
+ plugins: {
326
+ jsonc,
327
+ },
328
+ rules: {
329
+ ...jsonc.configs?.all?.rules,
330
+ ...jsonBase.rules,
331
+ },
332
+ },
333
+ {
334
+ files: [ "package.json" ],
335
+ languageOptions: {
336
+ parser: jsoncParser,
337
+ },
338
+ plugins: {
339
+ jsonc,
340
+ },
341
+ rules: {
342
+ ...jsonc.configs.all.rules,
343
+ ...jsonBase.rules,
344
+ "jsonc/sort-keys": [ "off" ],
345
+ },
346
+ },
347
+
348
+ // PHP files
349
+ {
350
+ files: [ "**.php" ],
351
+ plugins: {
352
+ "php-markup": phpMarkup,
353
+ },
354
+ languageOptions: {
355
+ globals: {
356
+ lintPHPCode: true,
357
+ },
358
+ },
359
+ settings: {
360
+ "php/php-extensions": [ ".php" ],
361
+ "php/markup-replacement": {
362
+ "php": "0",
363
+ "=": "0",
364
+ },
365
+ "php/keep-eol": true,
366
+ "php/remove-whitespace": false,
367
+ "php/remove-empty-line": false,
368
+ "php/remove-php-lint": false,
369
+ },
370
+ },
371
+
372
+ // Test files
373
+ {
374
+ files: [
375
+ "**/test/**",
376
+ "**/tests/**",
377
+ "**/spec/**",
378
+ "**/__tests__/**",
379
+ "**/*.test.*",
380
+ "**/*.spec.*",
381
+ "**/*.e2e.*",
382
+ "**/*.e2e-spec.*",
383
+ ],
384
+ languageOptions: {
385
+ globals: {
386
+ ...globals.vitest,
387
+ },
388
+ },
389
+ rules: {
390
+ ...typescriptTests.rules,
391
+ },
392
+ },
393
+
394
+ // INI/TOML files
395
+ {
396
+ files: [ ".env.example", ".env.*", "*.env", ".env.sample", "**/*.properties", "**/*.ini", "**/*.toml" ],
397
+ languageOptions: {
398
+ parser: tomlParser,
399
+ },
400
+ plugins: {
401
+ toml,
402
+ },
403
+ rules: {
404
+ ...iniBase.rules,
405
+ },
406
+ },
407
+
408
+ // YAML files
409
+ {
410
+ files: [ "**/*.yml", "**/*.yaml" ],
411
+ languageOptions: {
412
+ parser: yamlParser,
413
+ parserOptions: {
414
+ defaultYAMLVersion: "1.2",
415
+ },
416
+ },
417
+ plugins: {
418
+ yml,
419
+ },
420
+ rules: {
421
+ ...yamlBase.rules,
422
+ },
423
+ },
424
+ {
425
+ files: [ ".github/**/*.yml", ".github/**/*.yaml" ],
426
+ languageOptions: {
427
+ parser: yamlParser,
428
+ parserOptions: {
429
+ defaultYAMLVersion: "1.2",
430
+ },
431
+ },
432
+ plugins: {
433
+ yml,
434
+ },
435
+ rules: {
436
+ ...yamlGithub.rules,
437
+ },
438
+ },
439
+
440
+ // Any files
441
+ {
442
+ files: [
443
+ ".gitignore",
444
+ ".npmignore",
445
+ "**/*ignore",
446
+ "**/*.md",
447
+ "**/*.bash",
448
+ "**/*.sh",
449
+ "**/*.ps1",
450
+ "**/*.powershell",
451
+ "**/*.java",
452
+ "**/*.tf",
453
+ "Jenkinsfile",
454
+ "Dockerfile",
455
+ ],
456
+ languageOptions: {
457
+ parser: anyParser,
458
+ },
459
+ rules: {
460
+ ...anyBase.rules,
461
+ },
462
+ },
463
+ ];
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@odg/eslint-config",
3
- "version": "2.0.3",
3
+ "version": "3.0.0",
4
4
  "description": "Linter for JavaScript And Typescript project",
5
- "main": "index.js",
5
+ "type": "module",
6
+ "main": "index.mjs",
6
7
  "author": "Dragons Gamers <https://www.linkedin.com/in/victor-alves-odgodinho>",
7
8
  "scripts": {
8
- "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json,.jsonc,.json5,.yml,.yaml,.xml,.txt,.svg,.properties,.gradle,.java,.cpp,.c,.cs,.html,.css,.groovy,.gitignore,.npmignore,.toml,.env,.example,.sample,.ini,.php,.bat,.powershell,.ps1,.sh,.bash,.eslintrc"
9
+ "lint": "eslint",
10
+ "lint:fix": "eslint --fix"
11
+ },
12
+ "engines": {
13
+ "node": ">=24.0.0"
9
14
  },
10
15
  "repository": {
11
16
  "type": "git",
@@ -14,51 +19,51 @@
14
19
  "license": "MIT",
15
20
  "devDependencies": {
16
21
  "@odg/tsconfig": "*",
17
- "@types/node": ">=16",
22
+ "@types/node": ">=24",
18
23
  "typescript": "*"
19
24
  },
20
25
  "peerDependencies": {
21
26
  "@typescript-eslint/parser": "*",
22
- "eslint": "^8"
27
+ "eslint": "^9"
23
28
  },
24
29
  "dependencies": {
25
30
  "@babel/core": "*",
26
31
  "@odg/eslint-plugin": "*",
27
- "@stylistic/eslint-plugin-js": "^2.6.1",
28
- "@stylistic/eslint-plugin-plus": "^2.6.1",
29
- "@stylistic/eslint-plugin-ts": "^2.6.1",
30
- "@typescript-eslint/eslint-plugin": "^8.0.0",
31
- "@typescript-eslint/parser": "^8.0.0",
32
+ "@stylistic/eslint-plugin": "^5.7.0",
33
+ "@typescript-eslint/eslint-plugin": "^8.53.0",
34
+ "@typescript-eslint/parser": "^8.53.0",
32
35
  "any-eslint-parser": "^1.0.1",
33
- "eslint": "^8",
34
- "eslint-import-resolver-typescript": "^3.6.1",
35
- "eslint-plugin-antfu": "^0.40.3",
36
- "eslint-plugin-array-func": "^4.0.0",
37
- "eslint-plugin-better-max-params": "^0.0.1",
38
- "eslint-plugin-file-progress": "^1.4.0",
36
+ "eslint": "^9.39.2",
37
+ "eslint-import-resolver-typescript": "^4.4.4",
38
+ "eslint-plugin-antfu": "^3.1.3",
39
+ "eslint-plugin-array-func": "^5.1.0",
40
+ "eslint-plugin-better-max-params": "^1.0.0",
41
+ "eslint-plugin-file-progress": "^3.0.2",
39
42
  "eslint-plugin-filenames": "^1.3.2",
40
- "eslint-plugin-html": "^8.1.1",
41
- "eslint-plugin-import": "^2.29.1",
42
- "eslint-plugin-jsdoc": "^46.8.2",
43
- "eslint-plugin-json-schema-validator": "^5.1.2",
44
- "eslint-plugin-jsonc": "^2.16.0",
45
- "eslint-plugin-n": "^17.10.1",
43
+ "eslint-plugin-html": "^8.1.3",
44
+ "eslint-plugin-import": "^2.32.0",
45
+ "eslint-plugin-jsdoc": "^62.0.0",
46
+ "eslint-plugin-json-schema-validator": "^5.5.1",
47
+ "eslint-plugin-jsonc": "2.21.0",
48
+ "eslint-plugin-n": "^17.23.2",
46
49
  "eslint-plugin-no-constructor-bind": "^2.0.4",
47
50
  "eslint-plugin-php-markup": "^6.0.0",
48
- "eslint-plugin-promise": "^7.0.0",
51
+ "eslint-plugin-promise": "^7.2.1",
49
52
  "eslint-plugin-regex": "^1.10.0",
50
- "eslint-plugin-regexp": "^2.6.0",
53
+ "eslint-plugin-regexp": "^2.10.0",
51
54
  "eslint-plugin-security": "^3.0.1",
52
- "eslint-plugin-sonar": "^0.13.0",
53
- "eslint-plugin-sonarjs": "^1.0.4",
54
- "eslint-plugin-sort-class-members": "^1.20.0",
55
- "eslint-plugin-toml": "^0.11.1",
56
- "eslint-plugin-unicorn": "^55.0.0",
57
- "eslint-plugin-yml": "^1.14.0",
58
- "toml-eslint-parser": "^0.10.0"
55
+ "eslint-plugin-sonarjs": "^3.0.5",
56
+ "eslint-plugin-sort-class-members": "^1.21.0",
57
+ "eslint-plugin-toml": "^1.0.1",
58
+ "eslint-plugin-unicorn": "^62.0.0",
59
+ "eslint-plugin-yml": "^1.19.1",
60
+ "espree": "^11.0.0",
61
+ "globals": "^17.0.0",
62
+ "toml-eslint-parser": "^1.0.3",
63
+ "yaml-eslint-parser": "^2.0.0"
59
64
  },
60
65
  "files": [
61
- "./index.js",
66
+ "./index.mjs",
62
67
  "./rules/"
63
68
  ],
64
69
  "bugs": {
@@ -0,0 +1,15 @@
1
+ export default {
2
+ rules: {
3
+ "filenames/match-regex": [ "off" ],
4
+ "@stylistic/max-len": [
5
+ "warn",
6
+ {
7
+ code: 120,
8
+ ignoreUrls: true,
9
+ ignoreStrings: true,
10
+ ignoreTemplateLiterals: true,
11
+ ignoreRegExpLiterals: true,
12
+ },
13
+ ], // Caracteres máximo por linhas
14
+ },
15
+ };