diff --git a/packages/eslint-config-smarthr/configs/eslint.js b/packages/eslint-config-smarthr/configs/eslint.js index 00eb8c9d..819bc483 100644 --- a/packages/eslint-config-smarthr/configs/eslint.js +++ b/packages/eslint-config-smarthr/configs/eslint.js @@ -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 は不要なので削除してください。', + }, + ], + }, + ], }, } ] diff --git a/packages/eslint-config-smarthr/configs/react.js b/packages/eslint-config-smarthr/configs/react.js index 6b6b310a..49edbc90 100644 --- a/packages/eslint-config-smarthr/configs/react.js +++ b/packages/eslint-config-smarthr/configs/react.js @@ -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: { @@ -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' } } ] diff --git a/packages/eslint-config-smarthr/package.json b/packages/eslint-config-smarthr/package.json index c713080d..0ba84598 100644 --- a/packages/eslint-config-smarthr/package.json +++ b/packages/eslint-config-smarthr/package.json @@ -11,7 +11,7 @@ }, "scripts": { "test": "vitest run", - "test:update-snapshot": "vitest --updateSnapshot" + "test:update-snapshot": "vitest -u" }, "repository": { "type": "git", diff --git a/packages/eslint-config-smarthr/test/__snapshots__/snapshot.test.js.snap b/packages/eslint-config-smarthr/test/__snapshots__/snapshot.test.js.snap index c72b10ab..9b4840e3 100644 --- a/packages/eslint-config-smarthr/test/__snapshots__/snapshot.test.js.snap +++ b/packages/eslint-config-smarthr/test/__snapshots__/snapshot.test.js.snap @@ -1193,10 +1193,10 @@ exports[`should match ESLint Configuration snapshot 1`] = ` "parser": "typescript-eslint/parser@8.19.1", "parserOptions": { "ecmaFeatures": { - "jax": true, "jsx": true, }, "ecmaVersion": 2018, + "jsxPragma": null, "sourceType": "module", }, "sourceType": "module", @@ -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", @@ -2212,7 +2226,7 @@ exports[`should match ESLint Configuration snapshot 1`] = ` 0, ], "react/jsx-uses-react": [ - 2, + 0, ], "react/jsx-uses-vars": [ 2, @@ -2287,7 +2301,7 @@ exports[`should match ESLint Configuration snapshot 1`] = ` 0, ], "react/react-in-jsx-scope": [ - 2, + 0, ], "react/require-render-return": [ 2,