@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 CHANGED
@@ -23,7 +23,7 @@ yarn add -D @petbee/eslint-config typescript prettier
23
23
 
24
24
  ### For ESLint v9.x (flat config)
25
25
 
26
- ```javascript
26
+ ```js
27
27
  // eslint.config.js
28
28
  import petbeeConfig from '@petbee/eslint-config'
29
29
 
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
- // Helper function to ensure configs are in the correct format for spreading
16
- const ensureArray = (config) => {
17
- if (!config) return []
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
- return []
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
- ...ensureArray(prettierConfig),
50
- ...ensureArray(errorsConfig),
51
- ...ensureArray(nodeConfig),
52
- ...ensureArray(styleConfig),
53
- ...ensureArray(variablesConfig),
54
- ...ensureArray(bestPracticesConfig),
55
- ...ensureArray(importsConfig),
56
- ...ensureArray(typescriptConfig),
57
- ...ensureArray(testsConfig),
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
@@ -1,4 +1,4 @@
1
- /* eslint-disable node/global-require */
1
+ /* eslint-disable n/global-require */
2
2
 
3
3
  exports.hasPackage = (pkg) => {
4
4
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/eslint-config",
3
- "version": "1.0.16",
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": "^5.15.0",
42
- "@typescript-eslint/parser": "^5.15.0",
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": "^9.0.0",
45
- "eslint-plugin-cypress": "^2.15.1",
46
- "eslint-plugin-import": "^2.29.0",
47
- "eslint-plugin-jest": "^27.6.0",
48
- "eslint-plugin-node": "^11.1.0",
49
- "eslint-plugin-prettier": "^5.0.1",
50
- "eslint-plugin-react": "7.33.2"
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": ">=5.0.0",
54
- "prettier": ">=2.4",
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": "18.2.37",
59
- "eslint": "8.53.0",
60
- "prettier": "3.0.3",
61
- "react": "18.2.0",
62
- "typescript": "5.2.2"
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": "c93961f575f961f43e9995e3b9d6b8bbddb5e0a6"
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/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-process-env.md
9
- 'node/no-process-env': 'off',
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/mysticatea/eslint-plugin-node/blob/master/docs/rules/callback-return.md
12
+ // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/callback-return.md
13
13
  //! too annoying
14
- 'node/callback-return': 'off',
14
+ 'n/callback-return': 'off',
15
15
 
16
16
  // Require all requires be top-level
17
- // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/global-require.md
18
- 'node/global-require': 'error',
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/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-new-require.md
22
- 'node/no-new-require': 'error',
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/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-path-concat.md
26
- 'node/no-path-concat': 'error',
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/mysticatea/eslint-plugin-node/blob/master/docs/rules/process-exit-as-throw.md
30
- 'node/process-exit-as-throw': 'error',
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/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-deprecated-api.md
34
- 'node/no-deprecated-api': 'error',
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/mysticatea/eslint-plugin-node/blob/master/docs/rules/prefer-promises/fs.md
38
- // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/prefer-promises/dns.md
39
- 'node/prefer-promises/fs': 'warn',
40
- 'node/prefer-promises/dns': 'warn',
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
@@ -6,3 +6,11 @@ module.exports = {
6
6
  'prettier/prettier': 'error',
7
7
  },
8
8
  }
9
+
10
+ // Flat config for ESLint v9 (no extends, plugins as object)
11
+ module.exports.flat = {
12
+ plugins: {
13
+ prettier: require('eslint-plugin-prettier'),
14
+ },
15
+ rules: module.exports.rules,
16
+ }
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
+ ]
@@ -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
+ }