Skip to content

Commit

Permalink
feat(eslint-config-smarthr)!: react 17+以降のルールに対応した (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroki0525 authored Feb 3, 2025
1 parent a3a0a31 commit 62adc79
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
13 changes: 13 additions & 0 deletions packages/eslint-config-smarthr/configs/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ export default [
'vars-on-top': 'warn',
'wrap-iife': ['error', 'any'],
'yield-star-spacing': ['error', 'after'],
'no-restricted-imports': [
'error',
{
paths: [
{
// `import React from 'react';` を禁止する
name: 'react',
importNames: ['default'],
message: 'React 17+ では default import は不要なので削除してください。',
},
],
},
],
},
}
]
7 changes: 6 additions & 1 deletion packages/eslint-config-smarthr/configs/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export default [
languageOptions: {
parserOptions: {
ecmaFeatures: {
jax: true,
jsx: true,
},
// https://github.com/jsx-eslint/eslint-plugin-react/blob/e6b5b41191690ee166d0cca1e9db27092b910f03/index.js#L86
jsxPragma: null, // for @typescript/eslint-parser
},
},
settings: {
Expand Down Expand Up @@ -82,6 +84,9 @@ export default [
'react/prop-types': 'off',
'react/style-prop-object': 'error',
'react/void-dom-elements-no-children': 'error',
// https://github.com/jsx-eslint/eslint-plugin-react/blob/e6b5b41191690ee166d0cca1e9db27092b910f03/index.js#L89
'react/react-in-jsx-scope': 'off',
'react/jsx-uses-react': 'off'
}
}
]
2 changes: 1 addition & 1 deletion packages/eslint-config-smarthr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"scripts": {
"test": "vitest run",
"test:update-snapshot": "vitest --updateSnapshot"
"test:update-snapshot": "vitest -u"
},
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1193,10 +1193,10 @@ exports[`should match ESLint Configuration snapshot 1`] = `
"parser": "typescript-eslint/[email protected]",
"parserOptions": {
"ecmaFeatures": {
"jax": true,
"jsx": true,
},
"ecmaVersion": 2018,
"jsxPragma": null,
"sourceType": "module",
},
"sourceType": "module",
Expand Down Expand Up @@ -1906,6 +1906,20 @@ exports[`should match ESLint Configuration snapshot 1`] = `
"no-reserved-keys": [
0,
],
"no-restricted-imports": [
2,
{
"paths": [
{
"importNames": [
"default",
],
"message": "React 17+ では default import は不要なので削除してください。",
"name": "react",
},
],
},
],
"no-return-assign": [
2,
"except-parens",
Expand Down Expand Up @@ -2212,7 +2226,7 @@ exports[`should match ESLint Configuration snapshot 1`] = `
0,
],
"react/jsx-uses-react": [
2,
0,
],
"react/jsx-uses-vars": [
2,
Expand Down Expand Up @@ -2287,7 +2301,7 @@ exports[`should match ESLint Configuration snapshot 1`] = `
0,
],
"react/react-in-jsx-scope": [
2,
0,
],
"react/require-render-return": [
2,
Expand Down

0 comments on commit 62adc79

Please sign in to comment.