nishimura.clubnishimura.club

Next.jsにほぼESLintだけ入れる

作成日
2021-06-07
更新日
2021-06-07

最低限、セミコロンやクウォートなどを整理したいケースが多いのでメモ。

インストール

yarn add -D eslint eslint-plugin-react

設定

.eslintrc.jsを作成

module.exports = { root: true, env: { node: true, es6: true, }, parserOptions: { // Parsing error: 'import' and 'export' may appear only with 'sourceType: module' 対策 sourceType: 'module', // eslint Parsing error: Unexpected token function with async 対策 ecmaVersion: 8 }, plugins: [ 'react' ], ignorePatterns: [ 'node_modules/*', '.next/*', 'out/*', ], extends: [ 'eslint:recommended', 'plugin:react/recommended' ], // https://eslint.org/docs/rules/ を参照 rules: { 'semi': ['error', 'never'], 'react/react-in-jsx-scope': 'off', // めっちゃエラー出るので 'react/prop-types': 'off' // めっちゃエラー出るので } }

実行

package.json

"scripts": { "lint": "eslint --ext js,jsx --fix ." }

実行

yarn lint

VSCode設定

// .vscode/settings.json { "editor.formatOnSave": false, "editor.codeActionsOnSave": { "source.fixAll.eslint": true } }

Related

Tags

NextJS
NodeJS

Share