Skip to content

Commit 1a94532

Browse files
committed
feat: make eslint config composable
1 parent baf5c93 commit 1a94532

File tree

13 files changed

+180
-98
lines changed

13 files changed

+180
-98
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"dependencies": {
6767
"@babel/core": "^7.20.12",
6868
"@babel/eslint-parser": "^7.19.1",
69+
"@next/eslint-plugin-next": "^13.1.6",
6970
"@typescript-eslint/eslint-plugin": "^5.48.1",
7071
"@typescript-eslint/parser": "^5.48.1",
7172
"eslint": "^8.31.0",

pnpm-lock.yaml

Lines changed: 53 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/eslint.ts

Lines changed: 0 additions & 87 deletions
This file was deleted.

src/eslint/base.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const { ECMA_VERSION } = require('./constants')
2+
3+
module.exports = {
4+
env: {
5+
[`es${ECMA_VERSION}`]: true,
6+
},
7+
8+
// Report unused `eslint-disable` comments.
9+
reportUnusedDisableDirectives: true,
10+
11+
extends: ['eslint:recommended', 'plugin:import/recommended', 'plugin:prettier/recommended'],
12+
13+
rules: {
14+
'prettier/prettier': 1,
15+
16+
'sort-imports': [1, { ignoreDeclarationSort: true }],
17+
18+
'import/order': [
19+
1,
20+
{
21+
'newlines-between': 'always',
22+
alphabetize: { order: 'asc' },
23+
warnOnUnassignedImports: false,
24+
pathGroups: [
25+
{
26+
pattern: 'react',
27+
group: 'builtin',
28+
position: 'before',
29+
},
30+
],
31+
pathGroupsExcludedImportTypes: ['react'],
32+
},
33+
],
34+
'import/first': 1,
35+
'import/newline-after-import': 1,
36+
37+
'func-style': [1, 'declaration', { allowArrowFunctions: true }],
38+
},
39+
}

src/eslint/browser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
extends: require.resolve('./base'),
3+
env: {
4+
browser: true,
5+
},
6+
}

src/eslint/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
ECMA_VERSION: 2021,
3+
JAVASCRIPT_FILES: ['*.js?(x)', '*.mjs'],
4+
TYPESCRIPT_FILES: ['*.ts?(x)'],
5+
}

src/eslint/next.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['plugin:@next/next/recommended'],
3+
}

src/eslint/node.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
extends: require.resolve('./base'),
3+
env: {
4+
node: true,
5+
},
6+
}

src/eslint/react.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
module.exports = {
2+
extends: [
3+
'plugin:react/recommended',
4+
'plugin:react/jsx-runtime',
5+
'plugin:react-hooks/recommended',
6+
],
7+
rules: {
8+
'react/jsx-sort-props': [
9+
1,
10+
{
11+
callbacksLast: true,
12+
shorthandFirst: true,
13+
shorthandLast: false,
14+
ignoreCase: false,
15+
noSortAlphabetically: false,
16+
reservedFirst: true,
17+
},
18+
],
19+
'import/order': [
20+
1,
21+
{
22+
'newlines-between': 'always',
23+
alphabetize: { order: 'asc' },
24+
warnOnUnassignedImports: false,
25+
pathGroups: [
26+
{
27+
pattern: 'react',
28+
group: 'builtin',
29+
position: 'before',
30+
},
31+
],
32+
pathGroupsExcludedImportTypes: ['react'],
33+
},
34+
],
35+
},
36+
settings: {
37+
react: {
38+
version: 'detect',
39+
},
40+
},
41+
}

src/eslint/tailwindcss.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
extends: ['plugin:tailwindcss/recommended'],
3+
rules: {
4+
'tailwindcss/no-custom-classname': 0,
5+
},
6+
}

0 commit comments

Comments
 (0)