@petbee/eslint-config 1.0.17 → 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
@@ -13,36 +13,17 @@ import importsConfig from './rules/imports.js'
13
13
  import typescriptConfig from './rules/typescript.js'
14
14
  import testsConfig from './rules/tests.js'
15
15
 
16
- // Helper function to ensure configs are in the correct format for spreading
17
- const ensureArray = (config) => {
18
- if (!config) return []
19
- if (Array.isArray(config)) return config
20
-
21
- // Convert legacy config format to flat config format
22
- if (config.rules || config.extends || config.plugins) {
23
- const flatConfig = { ...config }
24
-
25
- // Convert env to languageOptions.globals
26
- if (flatConfig.env) {
27
- flatConfig.languageOptions = flatConfig.languageOptions || {}
28
- flatConfig.languageOptions.globals = flatConfig.languageOptions.globals || {}
29
-
30
- // Map common environments to globals
31
- if (flatConfig.env.node) Object.assign(flatConfig.languageOptions.globals, globals.node)
32
- if (flatConfig.env.jest) Object.assign(flatConfig.languageOptions.globals, globals.jest)
33
- if (flatConfig.env.es6) Object.assign(flatConfig.languageOptions.globals, globals.es2015)
34
-
35
- // Remove the env property
36
- delete flatConfig.env
37
- }
38
-
39
- return [flatConfig]
40
- }
16
+ const ignoreConfig = {
17
+ ignores: ['node_modules/', 'coverage/', 'dist/'],
18
+ }
41
19
 
42
- 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]) : []
43
23
  }
44
24
 
45
25
  export default [
26
+ ignoreConfig,
46
27
  js.configs.recommended,
47
28
  {
48
29
  files: ['**/*.ts', '**/*.tsx'],
@@ -57,20 +38,20 @@ export default [
57
38
  ...globals.jest,
58
39
  ...globals.es2015,
59
40
  __DEV__: true,
60
- }
41
+ },
61
42
  },
62
43
  plugins: {
63
44
  '@typescript-eslint': tsPlugin,
64
45
  },
65
46
  settings: {},
66
47
  },
67
- ...ensureArray(prettierConfig),
68
- ...ensureArray(errorsConfig),
69
- ...ensureArray(nodeConfig),
70
- ...ensureArray(styleConfig),
71
- ...ensureArray(variablesConfig),
72
- ...ensureArray(bestPracticesConfig),
73
- ...ensureArray(importsConfig),
74
- ...ensureArray(typescriptConfig),
75
- ...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),
76
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.17",
3
+ "version": "2.0.0",
4
4
  "description": "Petbee's eslint config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -38,33 +38,31 @@
38
38
  "url": "https://github.com/petbee/typescript/issues"
39
39
  },
40
40
  "dependencies": {
41
- "@eslint/js": "^9.0.0",
42
- "@typescript-eslint/eslint-plugin": "^5.15.0",
43
- "@typescript-eslint/parser": "^5.15.0",
41
+ "@typescript-eslint/eslint-plugin": "^8.32.1",
42
+ "@typescript-eslint/parser": "^8.32.1",
44
43
  "confusing-browser-globals": "^1.0.11",
45
- "eslint-config-prettier": "^9.0.0",
46
- "eslint-plugin-cypress": "^2.15.1",
47
- "eslint-plugin-import": "^2.29.0",
48
- "eslint-plugin-jest": "^27.6.0",
49
- "eslint-plugin-node": "^11.1.0",
50
- "eslint-plugin-prettier": "^5.0.1",
51
- "eslint-plugin-react": "7.33.2",
52
- "globals": "^13.24.0"
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"
53
51
  },
54
52
  "peerDependencies": {
55
- "eslint": ">=5.0.0",
56
- "prettier": ">=2.4",
53
+ "eslint": ">=9.0.0",
54
+ "prettier": ">=3.0.0",
57
55
  "typescript": "^4.0.0 || ^5.0.0"
58
56
  },
59
57
  "devDependencies": {
60
- "@types/react": "18.2.37",
61
- "eslint": "8.53.0",
62
- "prettier": "3.0.3",
63
- "react": "18.2.0",
64
- "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"
65
63
  },
66
64
  "publishConfig": {
67
65
  "access": "public"
68
66
  },
69
- "gitHead": "60105fc255d4bdf8c41303eda54123b70cacc52c"
67
+ "gitHead": "16e717a08300a1d7afc9e0b0fe28642d7b61b752"
70
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
+ }