@petbee/eslint-config 1.0.16 → 1.0.17

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.
Files changed (2) hide show
  1. package/eslint.config.mjs +28 -10
  2. package/package.json +5 -3
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'
@@ -16,8 +17,27 @@ import testsConfig from './rules/tests.js'
16
17
  const ensureArray = (config) => {
17
18
  if (!config) return []
18
19
  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]
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
+ }
21
41
 
22
42
  return []
23
43
  }
@@ -32,19 +52,17 @@ export default [
32
52
  project: './tsconfig.json',
33
53
  sourceType: 'module',
34
54
  },
55
+ globals: {
56
+ ...globals.node,
57
+ ...globals.jest,
58
+ ...globals.es2015,
59
+ __DEV__: true,
60
+ }
35
61
  },
36
62
  plugins: {
37
63
  '@typescript-eslint': tsPlugin,
38
64
  },
39
65
  settings: {},
40
- env: {
41
- node: true,
42
- jest: true,
43
- es6: true,
44
- },
45
- globals: {
46
- __DEV__: true,
47
- },
48
66
  },
49
67
  ...ensureArray(prettierConfig),
50
68
  ...ensureArray(errorsConfig),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/eslint-config",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Petbee's eslint config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -38,6 +38,7 @@
38
38
  "url": "https://github.com/petbee/typescript/issues"
39
39
  },
40
40
  "dependencies": {
41
+ "@eslint/js": "^9.0.0",
41
42
  "@typescript-eslint/eslint-plugin": "^5.15.0",
42
43
  "@typescript-eslint/parser": "^5.15.0",
43
44
  "confusing-browser-globals": "^1.0.11",
@@ -47,7 +48,8 @@
47
48
  "eslint-plugin-jest": "^27.6.0",
48
49
  "eslint-plugin-node": "^11.1.0",
49
50
  "eslint-plugin-prettier": "^5.0.1",
50
- "eslint-plugin-react": "7.33.2"
51
+ "eslint-plugin-react": "7.33.2",
52
+ "globals": "^13.24.0"
51
53
  },
52
54
  "peerDependencies": {
53
55
  "eslint": ">=5.0.0",
@@ -64,5 +66,5 @@
64
66
  "publishConfig": {
65
67
  "access": "public"
66
68
  },
67
- "gitHead": "c93961f575f961f43e9995e3b9d6b8bbddb5e0a6"
69
+ "gitHead": "60105fc255d4bdf8c41303eda54123b70cacc52c"
68
70
  }