Skip to content

Commit 94789c2

Browse files
committed
refactor: add eslint-define-config
1 parent ea1b480 commit 94789c2

File tree

12 files changed

+1849
-1542
lines changed

12 files changed

+1849
-1542
lines changed

packages/eslint-config-basic/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module.exports = {
1+
const { defineConfig } = require('eslint-define-config')
2+
3+
module.exports = defineConfig({
24
env: {
35
es6: true,
46
browser: true,
@@ -376,4 +378,4 @@ module.exports = {
376378
'coderwyd/top-level-function': 'error',
377379
// 'coderwyd/prefer-inline-type-import': 'error',
378380
},
379-
}
381+
})

packages/eslint-config-basic/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"eslint": ">=7.4.0"
2020
},
2121
"dependencies": {
22+
"eslint-define-config": "^1.22.0",
2223
"eslint-plugin-coderwyd": "workspace:*",
2324
"eslint-plugin-eslint-comments": "^3.2.0",
2425
"eslint-plugin-html": "^7.1.0",

packages/eslint-config-basic/standard.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Inline from https://github.com/standard/eslint-config-standard/blob/master/.eslintrc.json
22
// Until it upgrades
33

4-
module.exports = {
4+
const { defineConfig } = require('eslint-define-config')
5+
6+
module.exports = defineConfig({
57
parserOptions: {
68
ecmaVersion: 2022,
79
ecmaFeatures: {
@@ -244,4 +246,4 @@ module.exports = {
244246

245247
'promise/param-names': 'error',
246248
},
247-
}
249+
})

packages/eslint-config-react/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module.exports = {
1+
const { defineConfig } = require('eslint-define-config')
2+
3+
module.exports = defineConfig({
24
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended', '@coderwyd/eslint-config-ts'],
35
settings: {
46
react: {
@@ -9,4 +11,4 @@ module.exports = {
911
'jsx-quotes': ['error', 'prefer-double'],
1012
'react/react-in-jsx-scope': 'off',
1113
},
12-
}
14+
})

packages/eslint-config-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@coderwyd/eslint-config-ts": "workspace:*",
23+
"eslint-define-config": "^1.22.0",
2324
"eslint-plugin-react": "^7.33.1",
2425
"eslint-plugin-react-hooks": "^4.6.0"
2526
},

packages/eslint-config-ts/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
const fs = require('node:fs')
22
const { join } = require('node:path')
33
const process = require('node:process')
4+
const { defineConfig } = require('eslint-define-config')
45
const basic = require('@coderwyd/eslint-config-basic')
56

67
const tsconfig = process.env.ESLINT_TSCONFIG || 'tsconfig.eslint.json'
78

8-
module.exports = {
9+
module.exports = defineConfig({
910
extends: ['@coderwyd/eslint-config-basic', 'plugin:import/typescript', 'plugin:@typescript-eslint/recommended'],
1011
settings: {
1112
'import/resolver': {
1213
node: { extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.d.ts'] },
1314
},
1415
},
16+
// ignorePatterns: ['auto-import.d.ts', 'components.d.ts'],
1517
overrides: basic.overrides.concat(
1618
!fs.existsSync(join(process.cwd(), tsconfig))
1719
? []
@@ -182,4 +184,4 @@ module.exports = {
182184
// handled by unused-imports/no-unused-imports
183185
'@typescript-eslint/no-unused-vars': 'off',
184186
},
185-
}
187+
})

packages/eslint-config-ts/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"@coderwyd/eslint-config-basic": "workspace:*",
2121
"@typescript-eslint/eslint-plugin": "^6.2.1",
2222
"@typescript-eslint/parser": "^6.2.1",
23-
"eslint-plugin-jest": "^27.2.3"
23+
"eslint-define-config": "^1.22.0",
24+
"eslint-plugin-jest": "^27.2.3",
25+
"typescript": "^5.1.6"
2426
},
2527
"devDependencies": {
2628
"eslint": "^8.46.0"

packages/eslint-config-vue/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
const { defineConfig } = require('eslint-define-config')
12
const { isPackageExists } = require('local-pkg')
23

34
const TS = isPackageExists('typescript')
45

56
if (!TS)
67
console.warn('[@coderwyd/eslint-config] TypeScript is not installed, fallback to JS only.')
78

8-
module.exports = {
9+
module.exports = defineConfig({
910
overrides: [
1011
{
1112
files: ['*.vue'],
@@ -109,4 +110,4 @@ module.exports = {
109110
'vue/space-unary-ops': ['error', { words: true, nonwords: false }],
110111
'vue/template-curly-spacing': 'error',
111112
},
112-
}
113+
})

packages/eslint-config-vue/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dependencies": {
1818
"@coderwyd/eslint-config-basic": "workspace:*",
1919
"@coderwyd/eslint-config-ts": "workspace:*",
20+
"eslint-define-config": "^1.22.0",
2021
"eslint-plugin-vue": "^9.16.1",
2122
"local-pkg": "^0.4.3"
2223
},

packages/eslint-config/package.json

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"license": "MIT",
77
"homepage": "https://github.com/coderwyd/eslint-config",
88
"keywords": [
9-
"eslint-config"
9+
"eslint-config",
10+
"eslint",
11+
"preset"
1012
],
1113
"main": "index.js",
1214
"files": [
@@ -16,20 +18,7 @@
1618
"eslint": ">=7.4.0"
1719
},
1820
"dependencies": {
19-
"@coderwyd/eslint-config-vue": "workspace:*",
20-
"@typescript-eslint/eslint-plugin": "^6.2.1",
21-
"@typescript-eslint/parser": "^6.2.1",
22-
"eslint-plugin-eslint-comments": "^3.2.0",
23-
"eslint-plugin-html": "^7.1.0",
24-
"eslint-plugin-import": "npm:eslint-plugin-i@2.28.0-2",
25-
"eslint-plugin-jsonc": "^2.9.0",
26-
"eslint-plugin-n": "^16.0.1",
27-
"eslint-plugin-promise": "^6.1.1",
28-
"eslint-plugin-unicorn": "^48.0.1",
29-
"eslint-plugin-vue": "^9.16.1",
30-
"eslint-plugin-yml": "^1.8.0",
31-
"jsonc-eslint-parser": "^2.3.0",
32-
"yaml-eslint-parser": "^1.2.2"
21+
"@coderwyd/eslint-config-vue": "workspace:*"
3322
},
3423
"devDependencies": {
3524
"eslint": "^8.46.0"

0 commit comments

Comments
 (0)