@petbee/eslint-config 1.0.16 → 2.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/README.md +1 -1
- package/eslint.config.mjs +23 -24
- package/lib/utils.js +1 -1
- package/package.json +18 -18
- package/rules/imports.js +8 -0
- package/rules/node.js +18 -18
- package/rules/prettier.js +8 -0
- package/rules/tests.js +19 -0
- package/rules/typescript.js +22 -0
package/README.md
CHANGED
package/eslint.config.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import js from '@eslint/js'
|
|
2
2
|
import parser from '@typescript-eslint/parser'
|
|
3
3
|
import tsPlugin from '@typescript-eslint/eslint-plugin'
|
|
4
|
+
import globals from 'globals'
|
|
4
5
|
|
|
5
6
|
import prettierConfig from './rules/prettier.js'
|
|
6
7
|
import errorsConfig from './rules/errors.js'
|
|
@@ -12,17 +13,17 @@ import importsConfig from './rules/imports.js'
|
|
|
12
13
|
import typescriptConfig from './rules/typescript.js'
|
|
13
14
|
import testsConfig from './rules/tests.js'
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (Array.isArray(config)) return config
|
|
19
|
-
// If it's an object with rules, convert to a config object
|
|
20
|
-
if (config.rules || config.extends || config.plugins) return [config]
|
|
16
|
+
const ignoreConfig = {
|
|
17
|
+
ignores: ['node_modules/', 'coverage/', 'dist/'],
|
|
18
|
+
}
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
// Helper to get the flat config if available, otherwise fallback
|
|
21
|
+
const getFlat = (config) => {
|
|
22
|
+
return config && config.flat ? (Array.isArray(config.flat) ? config.flat : [config.flat]) : []
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export default [
|
|
26
|
+
ignoreConfig,
|
|
26
27
|
js.configs.recommended,
|
|
27
28
|
{
|
|
28
29
|
files: ['**/*.ts', '**/*.tsx'],
|
|
@@ -32,27 +33,25 @@ export default [
|
|
|
32
33
|
project: './tsconfig.json',
|
|
33
34
|
sourceType: 'module',
|
|
34
35
|
},
|
|
36
|
+
globals: {
|
|
37
|
+
...globals.node,
|
|
38
|
+
...globals.jest,
|
|
39
|
+
...globals.es2015,
|
|
40
|
+
__DEV__: true,
|
|
41
|
+
},
|
|
35
42
|
},
|
|
36
43
|
plugins: {
|
|
37
44
|
'@typescript-eslint': tsPlugin,
|
|
38
45
|
},
|
|
39
46
|
settings: {},
|
|
40
|
-
env: {
|
|
41
|
-
node: true,
|
|
42
|
-
jest: true,
|
|
43
|
-
es6: true,
|
|
44
|
-
},
|
|
45
|
-
globals: {
|
|
46
|
-
__DEV__: true,
|
|
47
|
-
},
|
|
48
47
|
},
|
|
49
|
-
...
|
|
50
|
-
...
|
|
51
|
-
...
|
|
52
|
-
...
|
|
53
|
-
...
|
|
54
|
-
...
|
|
55
|
-
...
|
|
56
|
-
...
|
|
57
|
-
...
|
|
48
|
+
...getFlat(prettierConfig),
|
|
49
|
+
...getFlat(errorsConfig),
|
|
50
|
+
...getFlat(nodeConfig),
|
|
51
|
+
...getFlat(styleConfig),
|
|
52
|
+
...getFlat(variablesConfig),
|
|
53
|
+
...getFlat(bestPracticesConfig),
|
|
54
|
+
...getFlat(importsConfig),
|
|
55
|
+
...getFlat(typescriptConfig),
|
|
56
|
+
...getFlat(testsConfig),
|
|
58
57
|
]
|
package/lib/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@petbee/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Petbee's eslint config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -38,31 +38,31 @@
|
|
|
38
38
|
"url": "https://github.com/petbee/typescript/issues"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
42
|
-
"@typescript-eslint/parser": "^
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
42
|
+
"@typescript-eslint/parser": "^8.32.1",
|
|
43
43
|
"confusing-browser-globals": "^1.0.11",
|
|
44
|
-
"eslint-config-prettier": "^
|
|
45
|
-
"eslint-plugin-cypress": "^
|
|
46
|
-
"eslint-plugin-import": "^2.
|
|
47
|
-
"eslint-plugin-jest": "^
|
|
48
|
-
"eslint-plugin-
|
|
49
|
-
"eslint-plugin-prettier": "^5.0
|
|
50
|
-
"eslint-plugin-react": "7.
|
|
44
|
+
"eslint-config-prettier": "^10.1.5",
|
|
45
|
+
"eslint-plugin-cypress": "^4.3.0",
|
|
46
|
+
"eslint-plugin-import": "^2.31.0",
|
|
47
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
48
|
+
"eslint-plugin-n": "^17.18.0",
|
|
49
|
+
"eslint-plugin-prettier": "^5.4.0",
|
|
50
|
+
"eslint-plugin-react": "7.37.5"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"eslint": ">=
|
|
54
|
-
"prettier": ">=
|
|
53
|
+
"eslint": ">=9.0.0",
|
|
54
|
+
"prettier": ">=3.0.0",
|
|
55
55
|
"typescript": "^4.0.0 || ^5.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@types/react": "
|
|
59
|
-
"eslint": "
|
|
60
|
-
"prettier": "3.
|
|
61
|
-
"react": "
|
|
62
|
-
"typescript": "5.
|
|
58
|
+
"@types/react": "19.1.4",
|
|
59
|
+
"eslint": "9.27.0",
|
|
60
|
+
"prettier": "3.5.3",
|
|
61
|
+
"react": "19.1.0",
|
|
62
|
+
"typescript": "5.8.3"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "16e717a08300a1d7afc9e0b0fe28642d7b61b752"
|
|
68
68
|
}
|
package/rules/imports.js
CHANGED
|
@@ -46,3 +46,11 @@ module.exports = {
|
|
|
46
46
|
'import/no-self-import': 'error',
|
|
47
47
|
},
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
// Flat config for ESLint v9 (no extends, plugins as object)
|
|
51
|
+
module.exports.flat = {
|
|
52
|
+
plugins: {
|
|
53
|
+
import: require('eslint-plugin-import'),
|
|
54
|
+
},
|
|
55
|
+
rules: module.exports.rules,
|
|
56
|
+
}
|
package/rules/node.js
CHANGED
|
@@ -5,38 +5,38 @@ module.exports = {
|
|
|
5
5
|
},
|
|
6
6
|
rules: {
|
|
7
7
|
// Disallow use of process.env
|
|
8
|
-
// https://github.com/
|
|
9
|
-
'
|
|
8
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-process-env.md
|
|
9
|
+
'n/no-process-env': 'off',
|
|
10
10
|
|
|
11
11
|
// Enforce a callback to return
|
|
12
|
-
// https://github.com/
|
|
12
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/callback-return.md
|
|
13
13
|
//! too annoying
|
|
14
|
-
'
|
|
14
|
+
'n/callback-return': 'off',
|
|
15
15
|
|
|
16
16
|
// Require all requires be top-level
|
|
17
|
-
// https://github.com/
|
|
18
|
-
'
|
|
17
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/global-require.md
|
|
18
|
+
'n/global-require': 'error',
|
|
19
19
|
|
|
20
20
|
// Disallow use of new operator with the require function
|
|
21
|
-
// https://github.com/
|
|
22
|
-
'
|
|
21
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-new-require.md
|
|
22
|
+
'n/no-new-require': 'error',
|
|
23
23
|
|
|
24
24
|
// Disallow string concatenation with __dirname and __filename
|
|
25
|
-
// https://github.com/
|
|
26
|
-
'
|
|
25
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-path-concat.md
|
|
26
|
+
'n/no-path-concat': 'error',
|
|
27
27
|
|
|
28
28
|
// Make process.exit() expressions the same code path as throw
|
|
29
|
-
// https://github.com/
|
|
30
|
-
'
|
|
29
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/process-exit-as-throw.md
|
|
30
|
+
'n/process-exit-as-throw': 'error',
|
|
31
31
|
|
|
32
32
|
// Disallow deprecated APIs
|
|
33
|
-
// https://github.com/
|
|
34
|
-
'
|
|
33
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-deprecated-api.md
|
|
34
|
+
'n/no-deprecated-api': 'error',
|
|
35
35
|
|
|
36
36
|
// Encourages use of promise APIs instead o callback APIs
|
|
37
|
-
// https://github.com/
|
|
38
|
-
// https://github.com/
|
|
39
|
-
'
|
|
40
|
-
'
|
|
37
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/prefer-promises/fs.md
|
|
38
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/prefer-promises/dns.md
|
|
39
|
+
'n/prefer-promises/fs': 'warn',
|
|
40
|
+
'n/prefer-promises/dns': 'warn',
|
|
41
41
|
},
|
|
42
42
|
}
|
package/rules/prettier.js
CHANGED
package/rules/tests.js
CHANGED
|
@@ -63,3 +63,22 @@ module.exports = {
|
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
// Flat config for ESLint v9 (no extends, plugins as object)
|
|
68
|
+
module.exports.flat = [
|
|
69
|
+
{
|
|
70
|
+
files: module.exports.overrides[0].files,
|
|
71
|
+
plugins: {
|
|
72
|
+
cypress: require('eslint-plugin-cypress'),
|
|
73
|
+
},
|
|
74
|
+
rules: module.exports.overrides[0].rules,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
files: module.exports.overrides[1].files,
|
|
78
|
+
excludedFiles: module.exports.overrides[1].excludedFiles,
|
|
79
|
+
plugins: {
|
|
80
|
+
jest: require('eslint-plugin-jest'),
|
|
81
|
+
},
|
|
82
|
+
rules: module.exports.overrides[1].rules,
|
|
83
|
+
},
|
|
84
|
+
]
|
package/rules/typescript.js
CHANGED
|
@@ -279,3 +279,25 @@ module.exports = hasTypescript
|
|
|
279
279
|
],
|
|
280
280
|
}
|
|
281
281
|
: {}
|
|
282
|
+
|
|
283
|
+
// Flat config for ESLint v9 (no extends, plugins as object)
|
|
284
|
+
if (hasTypescript) {
|
|
285
|
+
const overrides = module.exports.overrides || []
|
|
286
|
+
module.exports.flat = [
|
|
287
|
+
{
|
|
288
|
+
files: overrides[0]?.files,
|
|
289
|
+
languageOptions: {
|
|
290
|
+
parser: require.resolve('@typescript-eslint/parser'),
|
|
291
|
+
parserOptions: overrides[0]?.parserOptions,
|
|
292
|
+
},
|
|
293
|
+
plugins: {
|
|
294
|
+
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
|
|
295
|
+
},
|
|
296
|
+
rules: overrides[0]?.rules,
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
files: overrides[1]?.files,
|
|
300
|
+
rules: overrides[1]?.rules,
|
|
301
|
+
},
|
|
302
|
+
]
|
|
303
|
+
}
|