Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 80a5104

Browse files
chore!: ESLint v9 + FlatConfig (#898)
* chore: typescript-eslint を最新化 * chore: ESLint を最新化 * chore: eslint-plugin-react-hooks を最新化 * chore: eslint-plugin-smarthr の最新バージョンのテスト(後にrevert) * chore: 大雑把に FlatConfig 移植 * chore: ESLint モジュールは読み込めるようにする * chore: 一通りの FlatConfig を動くようにする * chore: eslint-plugin-smarthr を更新 * chore: テストランナーを jest から vitest に変更する * chore: 既存のテストコードをすべて削除 * chore: print-config に成功するまで修正 * chore: typescript-eslint を最新化 * chore: eslint.js に既存ルールを追加 * chore: Prettier が聞いてなかったのを修正 * chore: fix conflict with master * yalc 関連ファイルを削除 * chore: スナップショットテストの仕組みを導入 * chore: add breakline * chore: CIで利用するNodeバージョンを変更 * chore: eslint-plugin-smarthr を最新化 * chore: eslint v8 以下はサポート対象外にする * chore: README を更新
1 parent b0b32d4 commit 80a5104

File tree

20 files changed

+3826
-598
lines changed

20 files changed

+3826
-598
lines changed

.circleci/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ commands:
1818
# run tests!
1919
- run: yarn test
2020
jobs:
21-
node-v18:
21+
node-v20:
2222
docker:
23-
- image: cimg/node:18.19
23+
- image: cimg/node:20.11
2424
steps:
2525
- run-test
26-
node-v20:
26+
node-v22:
2727
docker:
28-
- image: cimg/node:20.11
28+
- image: cimg/node:22.11.0
2929
steps:
3030
- run-test
3131

3232
workflows:
3333
multiple_builds:
3434
jobs:
35-
- node-v18
3635
- node-v20
36+
- node-v22

.eslintrc.js

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

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ yarn add --dev eslint-config-smarthr
1616

1717
## How to use
1818

19-
Add a following `.eslintrc.js` in your project.
19+
Add a following `eslint.config.js` in your project.
2020

2121
```js
22-
module.exports = {
23-
extends: 'smarthr'
24-
}
22+
import smarthr from 'eslint-config-smarthr'
23+
24+
export default [
25+
...smarthr,
26+
{
27+
// your project's configuration
28+
},
29+
]
2530
```
2631

2732
Run `eslint`!

configs/eslint.js

Lines changed: 133 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,136 @@
1-
module.exports = {
2-
extends: ['eslint:recommended'],
3-
plugins: ['import'],
4-
parserOptions: {
5-
ecmaVersion: 2018,
6-
sourceType: 'module',
7-
},
8-
env: {
9-
browser: true,
10-
es6: true,
11-
commonjs: true,
12-
},
13-
globals: {
14-
process: 'readonly',
15-
},
16-
rules: {
17-
'array-callback-return': 'warn',
18-
'arrow-body-style': ['error', 'as-needed'],
19-
'block-scoped-var': 'warn',
20-
curly: ['warn', 'multi-line'],
21-
'default-param-last': 'error',
22-
'dot-notation': 'error',
23-
eqeqeq: 'error',
24-
'import/no-duplicates': 'error',
25-
'import/no-useless-path-segments': 'error',
26-
'import/order': [
27-
'error',
28-
{
29-
groups: ['builtin', 'external', 'parent', 'sibling', 'index', 'object', 'type'],
30-
pathGroups: [
31-
{
32-
pattern: '@/**',
33-
group: 'parent',
34-
position: 'before',
1+
import js from '@eslint/js'
2+
import * as importPlugin from 'eslint-plugin-import'
3+
4+
/**
5+
* @type {import('eslint').Linter.Config}
6+
*/
7+
export default [
8+
{
9+
name: 'eslint-config-smarthr/eslint',
10+
plugins: {
11+
'import': importPlugin,
12+
},
13+
languageOptions: {
14+
parserOptions: {
15+
ecmaVersion: 2018,
16+
sourceType: 'module',
17+
}
18+
},
19+
rules: {
20+
...js.configs.recommended.rules,
21+
'array-callback-return': 'warn',
22+
'arrow-body-style': ['error', 'as-needed'],
23+
'block-scoped-var': 'warn',
24+
curly: ['warn', 'multi-line'],
25+
'default-param-last': 'error',
26+
'dot-notation': 'error',
27+
eqeqeq: 'error',
28+
'import/no-duplicates': 'error',
29+
'import/no-useless-path-segments': 'error',
30+
'import/order': [
31+
'error',
32+
{
33+
groups: ['builtin', 'external', 'parent', 'sibling', 'index', 'object', 'type'],
34+
pathGroups: [
35+
{
36+
pattern: '@/**',
37+
group: 'parent',
38+
position: 'before',
39+
},
40+
],
41+
alphabetize: {
42+
order: 'asc',
3543
},
36-
],
37-
alphabetize: {
38-
order: 'asc',
44+
'newlines-between': 'always',
45+
},
46+
],
47+
'no-async-promise-executor': 'error',
48+
'no-caller': 'error',
49+
'no-catch-shadow': 'error',
50+
'no-confusing-arrow': [
51+
'error',
52+
{
53+
allowParens: true,
54+
},
55+
],
56+
'no-div-regex': 'warn',
57+
'no-eval': 'error',
58+
'no-extend-native': 'error',
59+
'no-extra-parens': ['error', 'functions'],
60+
'no-floating-decimal': 'error',
61+
'no-implicit-globals': 'error',
62+
'no-implied-eval': 'error',
63+
'no-import-assign': 'error',
64+
'no-inner-declarations': 'warn',
65+
'no-iterator': 'error',
66+
'no-label-var': 'error',
67+
'no-lone-blocks': 'error',
68+
'no-loop-func': 'warn',
69+
'no-new-func': 'error',
70+
'no-new-wrappers': 'error',
71+
'no-octal-escape': 'error',
72+
'no-proto': 'error',
73+
'no-return-assign': 'error',
74+
'no-return-await': 'error',
75+
'no-script-url': 'warn',
76+
'no-self-compare': 'error',
77+
'no-sequences': 'error',
78+
'no-shadow': 'error',
79+
'no-shadow-restricted-names': 'error',
80+
'no-throw-literal': 'error',
81+
'no-unmodified-loop-condition': 'warn',
82+
'no-unused-expressions': [
83+
'error',
84+
{
85+
allowShortCircuit: true,
86+
allowTernary: true,
87+
},
88+
],
89+
'no-unused-vars': [
90+
'error',
91+
{
92+
vars: 'local',
93+
args: 'none',
94+
},
95+
],
96+
'no-useless-call': 'warn',
97+
'no-useless-computed-key': 'error',
98+
'no-useless-concat': 'error',
99+
'no-useless-rename': 'error',
100+
'no-var': 'error',
101+
'no-void': 'error',
102+
'no-with': 'error',
103+
'object-shorthand': ['error', 'properties'],
104+
'prefer-arrow-callback': 'warn',
105+
'prefer-const': [
106+
'warn',
107+
{
108+
destructuring: 'all',
109+
ignoreReadBeforeAssign: true,
110+
},
111+
],
112+
'prefer-numeric-literals': 'error',
113+
'prefer-regex-literals': 'error',
114+
'prefer-rest-params': 'error',
115+
'prefer-spread': 'warn',
116+
radix: 'error',
117+
'sort-imports': [
118+
'error',
119+
{
120+
ignoreDeclarationSort: true,
121+
},
122+
],
123+
'symbol-description': 'error',
124+
'template-curly-spacing': 'error',
125+
'valid-typeof': [
126+
'error',
127+
{
128+
requireStringLiterals: true,
39129
},
40-
'newlines-between': 'always',
41-
},
42-
],
43-
'no-async-promise-executor': 'error',
44-
'no-caller': 'error',
45-
'no-catch-shadow': 'error',
46-
'no-confusing-arrow': [
47-
'error',
48-
{
49-
allowParens: true,
50-
},
51-
],
52-
'no-div-regex': 'warn',
53-
'no-eval': 'error',
54-
'no-extend-native': 'error',
55-
'no-extra-parens': ['error', 'functions'],
56-
'no-floating-decimal': 'error',
57-
'no-implicit-globals': 'error',
58-
'no-implied-eval': 'error',
59-
'no-import-assign': 'error',
60-
'no-inner-declarations': 'warn',
61-
'no-iterator': 'error',
62-
'no-label-var': 'error',
63-
'no-lone-blocks': 'error',
64-
'no-loop-func': 'warn',
65-
'no-new-func': 'error',
66-
'no-new-wrappers': 'error',
67-
'no-octal-escape': 'error',
68-
'no-proto': 'error',
69-
'no-return-assign': 'error',
70-
'no-return-await': 'error',
71-
'no-script-url': 'warn',
72-
'no-self-compare': 'error',
73-
'no-sequences': 'error',
74-
'no-shadow': 'error',
75-
'no-shadow-restricted-names': 'error',
76-
'no-throw-literal': 'error',
77-
'no-unmodified-loop-condition': 'warn',
78-
'no-unused-expressions': [
79-
'error',
80-
{
81-
allowShortCircuit: true,
82-
allowTernary: true,
83-
},
84-
],
85-
'no-unused-vars': [
86-
'error',
87-
{
88-
vars: 'local',
89-
args: 'none',
90-
},
91-
],
92-
'no-useless-call': 'warn',
93-
'no-useless-computed-key': 'error',
94-
'no-useless-concat': 'error',
95-
'no-useless-rename': 'error',
96-
'no-var': 'error',
97-
'no-void': 'error',
98-
'no-with': 'error',
99-
'object-shorthand': ['error', 'properties'],
100-
'prefer-arrow-callback': 'warn',
101-
'prefer-const': [
102-
'warn',
103-
{
104-
destructuring: 'all',
105-
ignoreReadBeforeAssign: true,
106-
},
107-
],
108-
'prefer-numeric-literals': 'error',
109-
'prefer-regex-literals': 'error',
110-
'prefer-rest-params': 'error',
111-
'prefer-spread': 'warn',
112-
radix: 'error',
113-
'sort-imports': [
114-
'error',
115-
{
116-
ignoreDeclarationSort: true,
117-
},
118-
],
119-
'symbol-description': 'error',
120-
'template-curly-spacing': 'error',
121-
'valid-typeof': [
122-
'error',
123-
{
124-
requireStringLiterals: true,
125-
},
126-
],
127-
'vars-on-top': 'warn',
128-
'wrap-iife': ['error', 'any'],
129-
'yield-star-spacing': ['error', 'after'],
130-
},
131-
overrides: [
132-
{
133-
files: ['*.test.ts', '*.test.tsx', '*.test.js', '*.test.jsx'],
134-
env: {
135-
jest: true,
136-
},
130+
],
131+
'vars-on-top': 'warn',
132+
'wrap-iife': ['error', 'any'],
133+
'yield-star-spacing': ['error', 'after'],
137134
},
138-
],
139-
}
135+
}
136+
]

configs/prettier.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
module.exports = {
2-
extends: ['prettier'],
3-
}
1+
import Prettier from 'eslint-config-prettier'
2+
3+
/**
4+
* @type {import('eslint').Linter.Config}
5+
*/
6+
export default [
7+
{
8+
name: 'eslint-config-smarthr/prettier',
9+
rules: {
10+
...Prettier.rules,
11+
}
12+
}
13+
]

0 commit comments

Comments
 (0)