@petbee/eslint-config 1.0.13 → 1.0.15
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 +3 -0
- package/README.md +37 -2
- package/eslint-config.d.ts +10 -0
- package/eslint.config.mjs +18 -9
- package/index.js +1 -0
- package/package.json +4 -59
- package/tsconfig.json +3 -0
package/.eslintrc
ADDED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@petbee/eslint-config`
|
|
2
2
|
|
|
3
|
-
This package provides Petbee's
|
|
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
|
-
|
|
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,15 @@ 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
|
+
return []
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
export default [
|
|
16
25
|
js.configs.recommended,
|
|
17
26
|
{
|
|
@@ -36,13 +45,13 @@ export default [
|
|
|
36
45
|
__DEV__: true,
|
|
37
46
|
},
|
|
38
47
|
},
|
|
39
|
-
...prettierConfig,
|
|
40
|
-
...errorsConfig,
|
|
41
|
-
...nodeConfig,
|
|
42
|
-
...styleConfig,
|
|
43
|
-
...variablesConfig,
|
|
44
|
-
...bestPracticesConfig,
|
|
45
|
-
...importsConfig,
|
|
46
|
-
...typescriptConfig,
|
|
47
|
-
...testsConfig,
|
|
48
|
+
...ensureArray(prettierConfig),
|
|
49
|
+
...ensureArray(errorsConfig),
|
|
50
|
+
...ensureArray(nodeConfig),
|
|
51
|
+
...ensureArray(styleConfig),
|
|
52
|
+
...ensureArray(variablesConfig),
|
|
53
|
+
...ensureArray(bestPracticesConfig),
|
|
54
|
+
...ensureArray(importsConfig),
|
|
55
|
+
...ensureArray(typescriptConfig),
|
|
56
|
+
...ensureArray(testsConfig),
|
|
48
57
|
]
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@petbee/eslint-config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Petbee's eslint config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -13,63 +13,8 @@
|
|
|
13
13
|
".": {
|
|
14
14
|
"require": "./index.js",
|
|
15
15
|
"import": "./eslint.config.mjs"
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
|
+
"./legacy": "./index.js"
|
|
17
18
|
},
|
|
18
|
-
"
|
|
19
|
-
"files": [
|
|
20
|
-
"index.js",
|
|
21
|
-
"eslint.config.mjs",
|
|
22
|
-
"rules/",
|
|
23
|
-
"lib/"
|
|
24
|
-
],
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "https://github.com/petbee/typescript.git",
|
|
28
|
-
"directory": "packages/eslint-config"
|
|
29
|
-
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"eslint-check": "eslint-config-prettier index.js",
|
|
32
|
-
"dump-config": "eslint-config-prettier index.js > config-dump.json",
|
|
33
|
-
"format": "prettier --ignore-path='.gitignore' --list-different --write .",
|
|
34
|
-
"format:check": "prettier --ignore-path='.gitignore' --check .",
|
|
35
|
-
"lint": "eslint --ignore-path='.gitignore' '{src,tests}/**/*.{ts,tsx}'"
|
|
36
|
-
},
|
|
37
|
-
"eslintConfig": {
|
|
38
|
-
"extends": [
|
|
39
|
-
"petbee"
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
"prettier": "@petbee/prettier-config",
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/petbee/typescript/issues"
|
|
45
|
-
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
48
|
-
"@typescript-eslint/parser": "^5.15.0",
|
|
49
|
-
"confusing-browser-globals": "^1.0.11",
|
|
50
|
-
"eslint-config-prettier": "^9.0.0",
|
|
51
|
-
"eslint-plugin-cypress": "^2.15.1",
|
|
52
|
-
"eslint-plugin-import": "^2.29.0",
|
|
53
|
-
"eslint-plugin-jest": "^27.6.0",
|
|
54
|
-
"eslint-plugin-node": "^11.1.0",
|
|
55
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
56
|
-
"eslint-plugin-react": "7.33.2"
|
|
57
|
-
},
|
|
58
|
-
"peerDependencies": {
|
|
59
|
-
"eslint": ">=5.0.0",
|
|
60
|
-
"prettier": ">=2.4",
|
|
61
|
-
"typescript": "^4.0.0 || ^5.0.0"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@petbee/prettier-config": "^1.0.3",
|
|
65
|
-
"@types/react": "18.2.37",
|
|
66
|
-
"eslint": "8.53.0",
|
|
67
|
-
"prettier": "3.0.3",
|
|
68
|
-
"react": "18.2.0",
|
|
69
|
-
"typescript": "5.2.2"
|
|
70
|
-
},
|
|
71
|
-
"publishConfig": {
|
|
72
|
-
"access": "public"
|
|
73
|
-
},
|
|
74
|
-
"gitHead": "ea495ee514228c397760b9b595bfce1ef68ba352"
|
|
19
|
+
"gitHead": "49aa2f61479d9bdebb6e702856bc79e5f579393f"
|
|
75
20
|
}
|
package/tsconfig.json
ADDED