0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ESLintの基本

Posted at

今までなんとなく使っていたので、ちょっと調べてみた。

■ESLint・・・構文の間違いやルールに沿ってコードが記述されているかをチェックするツール
■Prettier・・・コードの整形をするフォーマッター

ESLint設定ファイル

ESLintではルールを.eslintrc.jsファイルのrulesに書く。

.eslintrc.js
module.exports = {
  省略
  rules: {
    @typescript-eslint/no-unused-vars: off,
    no-unused-vars: off,
       “quotes: [1, 'single'],
     “semi: ['error', 'always'],
    indent: [error, 2],
  },
};

ルールはここに載ってる・・・https://eslint.org/docs/latest/rules/
vueに関してはここ(https://eslint.vuejs.org/rules/)
エラーレベル・・・off、warn、error

Prettier設定ファイル

ESLintでもフォーマットできるのになぜPrettierを使うのかよくわかりませんが・・
いろいろできるのかな

.prettierrc
  "tabWidth": 4,
  "semi": false,
  "singleQuote": true

.eslintrc.jsファイルのrulesにprettierの設定も書けるみたい。

module.exports = {
  省略
  rules: {
    “@typescript-eslint/no-unused-vars”: “off”,
    “no-unused-vars”: “off”,
    "prettier/prettier": [
      "error",
      {
        tabWidth: 2,
        singleQuote: false,
        semi: true,
      },
    ],
  },
};
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?