Replies: 7 comments 31 replies
-
|
(2024/03/24 更新しました) Skyshareの場合は次の手順でESLintを導入できます。
module.exports = {
env: {
browser: true,
es2021: true,
},
overrides: [
{
files: ["*.astro"],
parser: "astro-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser",
extraFileExtensions: [".astro"],
},
processor: "astro/client-side-ts",
extends: [
"plugin:astro/recommended",
"plugin:astro/jsx-a11y-recommended",
],
},
{
files: ["*.{tsx, jsx}"],
extends: ["plugin:react/recommended", "plugin:react/jsx-runtime"],
},
{
files: [".eslintrc.{js,cjs}"],
env: {
node: true,
},
parserOptions: {
sourceType: "script",
},
extends: ["plugin:@typescript-eslint/disable-type-checked"],
},
{
files: ["tests/**/*"],
extends: ["plugin:@typescript-eslint/disable-type-checked"],
},
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"prettier",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["@typescript-eslint", "react"],
settings: {
react: {
version: "detect",
},
},
rules: {
indent: ["warn", 4, { SwitchCase: 1, MemberExpression: "off" }],
quotes: ["warn", "double"],
semi: ["warn", "never"],
"linebreak-style": ["warn", "unix"],
"no-irregular-whitespace": "warn",
"prefer-const": "warn",
"@typescript-eslint/strict-boolean-expressions": "warn",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{ destructuredArrayIgnorePattern: "^_" },
],
},
ignorePatterns: ["dist", "node_modules"],
}Footnotes
|
Beta Was this translation helpful? Give feedback.
-
|
既に出ていますが、静的なチェックはESLint husky+lint-stagedを導入すると、gitのpre-commitに割り込んで自動でフォーマットしてくれるため、 |
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
@ZEKE320 @so-asano 本Disscussion対応として、マイルストーンを設定しました。対応実施の目安としてよければ活用してください。 |
Beta Was this translation helpful? Give feedback.
-
|
リンティングエラーの対応方針はここでまとめましょうか (解決)
|
Beta Was this translation helpful? Give feedback.
-
(解決)
|
Beta Was this translation helpful? Give feedback.
-
(解決)union型における
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
LinterとFormatter導入の提案
Linterの導入
用途
コードを静的解析し、
などをマークします。
利点
具体的なLinter
ESLint
npmでパッケージをインストールしてESLint自体の拡張(AstroやReactの対応)ができる.eslintrc.jsonから設定可能SonarLint
@ext:sonarsource.sonarlint-vscode java homeと入力Sonarlint > Ls: Java HomeにインストールしたJDKのパスを指定する(画像では
/usr/local/sdkman/candidates/java/...から始まる箇所)Microsoft Edge Tools for VS Code (VS Codeの拡張機能)
Code Spell Checker (VS Codeの拡張機能)
cspell.jsonから設定可能Formatterの導入
用途
コードを自動で整形します。
利点
具体的なFormatter
Prettier
npmでパッケージをインストールしてPrettier自体の拡張(本プロジェクトでは特にAstroへの対応)ができる.prettierrcから設定可能Beta Was this translation helpful? Give feedback.
All reactions