@petbee/eslint-config 1.0.14 → 1.0.16

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/.eslintrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["./index.js"]
3
+ }
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@petbee/eslint-config`
2
2
 
3
- This package provides Petbee's `.eslintrc` as an extensible shared config.
3
+ This package provides Petbee's ESLint configuration as an extensible shared config, supporting both ESLint v9.x (flat config) and older versions (.eslintrc).
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,7 +12,42 @@ yarn add -D @petbee/eslint-config typescript prettier
12
12
 
13
13
  ## Usage
14
14
 
15
- After installing the module, just add it to your `extends` array inside your `.eslintrc`.
15
+ ### For ESLint v8.x and older (legacy config)
16
+
17
+ ```jsonc
18
+ // .eslintrc
19
+ {
20
+ "extends": ["@petbee/eslint-config"]
21
+ }
22
+ ```
23
+
24
+ ### For ESLint v9.x (flat config)
25
+
26
+ ```javascript
27
+ // eslint.config.js
28
+ import petbeeConfig from '@petbee/eslint-config'
29
+
30
+ export default [
31
+ ...petbeeConfig,
32
+ // Your custom configurations...
33
+ ]
34
+ ```
35
+
36
+ ### For projects using both ESLint versions
37
+
38
+ If you need to support both ESLint versions in the same project, you can:
39
+
40
+ ```javascript
41
+ // eslint.config.js
42
+ import petbeeConfig from '@petbee/eslint-config'
43
+
44
+ export default [
45
+ ...petbeeConfig,
46
+ // Your custom configurations...
47
+ ]
48
+ ```
49
+
50
+ And maintain a .eslintrc file:
16
51
 
17
52
  ```jsonc
18
53
  // .eslintrc
@@ -0,0 +1,10 @@
1
+ declare module '@petbee/eslint-config' {
2
+ import type { FlatConfig } from 'eslint'
3
+
4
+ // For ESLint v9.x (flat config)
5
+ const flatConfig: FlatConfig.Config[]
6
+ export default flatConfig
7
+
8
+ // For older ESLint versions (.eslintrc)
9
+ export const legacyConfig: Record<string, unknown>
10
+ }
package/eslint.config.mjs CHANGED
@@ -12,6 +12,16 @@ import importsConfig from './rules/imports.js'
12
12
  import typescriptConfig from './rules/typescript.js'
13
13
  import testsConfig from './rules/tests.js'
14
14
 
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]
21
+
22
+ return []
23
+ }
24
+
15
25
  export default [
16
26
  js.configs.recommended,
17
27
  {
@@ -36,13 +46,13 @@ export default [
36
46
  __DEV__: true,
37
47
  },
38
48
  },
39
- ...prettierConfig,
40
- ...errorsConfig,
41
- ...nodeConfig,
42
- ...styleConfig,
43
- ...variablesConfig,
44
- ...bestPracticesConfig,
45
- ...importsConfig,
46
- ...typescriptConfig,
47
- ...testsConfig,
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
58
  ]
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ // This is the legacy config for ESLint < 9.0
1
2
  module.exports = {
2
3
  parserOptions: {
3
4
  project: 'tsconfig.json',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/eslint-config",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Petbee's eslint config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -13,17 +13,9 @@
13
13
  ".": {
14
14
  "require": "./index.js",
15
15
  "import": "./eslint.config.mjs"
16
- }
16
+ },
17
+ "./legacy": "./index.js"
17
18
  },
18
- "main": "index.js",
19
- "types": "./eslint.config.d.ts",
20
- "files": [
21
- "index.js",
22
- "eslint.config.d.ts",
23
- "eslint.config.mjs",
24
- "rules/",
25
- "lib/"
26
- ],
27
19
  "repository": {
28
20
  "type": "git",
29
21
  "url": "https://github.com/petbee/typescript.git",
@@ -63,7 +55,6 @@
63
55
  "typescript": "^4.0.0 || ^5.0.0"
64
56
  },
65
57
  "devDependencies": {
66
- "@petbee/prettier-config": "^1.0.3",
67
58
  "@types/react": "18.2.37",
68
59
  "eslint": "8.53.0",
69
60
  "prettier": "3.0.3",
@@ -73,5 +64,5 @@
73
64
  "publishConfig": {
74
65
  "access": "public"
75
66
  },
76
- "gitHead": "d91314aafe3e270498397c41fe3332a21cc2fc75"
67
+ "gitHead": "c93961f575f961f43e9995e3b9d6b8bbddb5e0a6"
77
68
  }
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "@petbee/tsconfig/base.json"
3
+ }