Skip to content

Commit cd16e8f

Browse files
committedOct 9, 2023
feat!: update to eslint flat config
feat: add @IanVS/prettier-plugin-sort-imports
1 parent 495adda commit cd16e8f

10 files changed

+1306
-462
lines changed
 

‎.eslintrc

-3
This file was deleted.

‎.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
issues: write # to be able to comment on released issues
1313
pull-requests: write # to be able to comment on released pull requests
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- uses: pnpm/action-setup@v2
1717
with:
1818
version: 8

‎.prettierrc.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// prettier.config.js
2-
// some of these match the current Prettier defaults, but are left in for clarity
3-
module.exports = {
1+
export default {
42
arrowParens: 'always',
53
bracketSameLine: false,
64
endOfLine: 'lf',
@@ -9,5 +7,14 @@ module.exports = {
97
trailingComma: 'all',
108
semi: false,
119
singleAttributePerLine: false,
12-
plugins: ['prettier-plugin-tailwindcss'],
10+
plugins: ['@ianvs/prettier-plugin-sort-imports', 'prettier-plugin-tailwindcss'],
11+
tailwindFunctions: ['clsx'],
12+
importOrderTypeScriptVersion: '5.0.0',
13+
importOrder: [
14+
'<BUILT_IN_MODULES>',
15+
'<THIRD_PARTY_MODULES>',
16+
'^(?!.*[.]css$)[./].*$',
17+
'',
18+
'.css$',
19+
],
1320
}

‎.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{ // Enable the ESlint flat config support
2+
"eslint.experimental.useFlatConfig": true,
3+
}

‎README.md

+19-10
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,28 @@ It starts with his vue config and makes these changes:
2222
pnpm add -D eslint prettier @jcamp/eslint-config
2323
```
2424

25-
### Config `.eslintrc`
25+
### Config `eslint.config.js`
2626

27-
```json
28-
{
29-
"extends": "@jcamp"
30-
}
27+
```js
28+
import config from '@jcamp/eslint-config'
29+
30+
export default config
3131
```
3232

33-
> You don't need `.eslintignore` normally as it has been provided by the preset.
33+
> `.eslintignore` is no longer supported by [eslint flatconfig](https://eslint.org/docs/latest/use/configure/configuration-files-new#globally-ignoring-files-with-ignores).
34+
35+
```js
36+
config.push({
37+
ignores: ['temp.js', '**/vendor/*.js'],
38+
})
39+
```
3440

3541
### Config `.prettierrc.js`
3642

3743
```js
38-
const baseConfig = require('@jcamp/eslint-config/.prettierrc.js')
44+
import baseConfig from '@jcamp/eslint-config/prettier'
3945

40-
module.exports = {
46+
export default {
4147
...baseConfig,
4248
/* make any changes here */
4349
singleAttributePerLine: false,
@@ -66,12 +72,15 @@ Create `.vscode/settings.json`
6672
```json
6773
{
6874
"prettier.enable": true,
75+
// Enable the ESlint flat config support
76+
"eslint.experimental.useFlatConfig": true,
6977
"editor.codeActionsOnSave": {
70-
"source.fixAll.eslint": true
78+
"source.fixAll.eslint": "explicit",
79+
"source.organizeImports": "never"
7180
}
7281
}
7382
```
7483

7584
## License
7685

77-
[MIT](./LICENSE) License &copy; 2022-PRESENT [John Campion](https://github.com/JohnCampionJr/)
86+
[MIT](./LICENSE) License &copy; 2023-PRESENT [John Campion](https://github.com/JohnCampionJr/)

‎eslint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from './index.js'
2+
3+
export default config

‎index.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1-
module.exports = {
2-
extends: ['@antfu/eslint-config-vue', 'prettier'],
1+
import { antfu } from '@antfu/eslint-config'
2+
import eslintConfigPrettier from 'eslint-config-prettier'
3+
4+
const config = antfu({
5+
stylistic: false,
6+
vue: true,
7+
})
8+
config.push(eslintConfigPrettier)
9+
10+
config.push({
311
rules: {
4-
'antfu/if-newline': 'off',
12+
curly: ['error', 'all'],
13+
'vue/html-self-closing': [
14+
'error',
15+
{
16+
html: {
17+
void: 'any',
18+
},
19+
},
20+
],
521
},
6-
}
22+
})
23+
24+
export default config

‎package.json

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@jcamp/eslint-config",
3+
"type": "module",
34
"version": "0.8.2",
45
"description": "JohnCampionJr's ESLint config",
56
"author": "John Campion (https://github.com/JohnCampionJr/)",
@@ -9,10 +10,14 @@
910
"eslint-config",
1011
"prettier"
1112
],
13+
"exports": {
14+
".": "./index.js",
15+
"./prettier": "./.prettierrc.js"
16+
},
1217
"main": "index.js",
1318
"files": [
14-
"index.js",
15-
".prettierrc.js"
19+
".prettierrc.js",
20+
"index.js"
1621
],
1722
"scripts": {
1823
"lint": "eslint .",
@@ -21,16 +26,17 @@
2126
"clean": "prettier . --write"
2227
},
2328
"peerDependencies": {
24-
"eslint": ">=8.50.0",
29+
"eslint": ">=8.51.0",
2530
"prettier": ">=3.0.3"
2631
},
2732
"dependencies": {
28-
"@antfu/eslint-config-vue": "^0.43.1",
29-
"eslint-config-prettier": "^8.10.0",
30-
"prettier-plugin-tailwindcss": "^0.5.4"
33+
"@antfu/eslint-config": "^1.0.0-beta.22",
34+
"@ianvs/prettier-plugin-sort-imports": "^4.1.0",
35+
"eslint-config-prettier": "^9.0.0",
36+
"prettier-plugin-tailwindcss": "^0.5.5"
3137
},
3238
"devDependencies": {
33-
"eslint": "^8.50.0",
39+
"eslint": "^8.51.0",
3440
"prettier": "^3.0.3"
3541
}
3642
}

‎pnpm-lock.yaml

+1,234-423
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎tsconfig.json

-10
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.