1
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 - .eslintrc のファイル形式・拡張子

Posted at

ファイル形式

色々なファイル形式に対応している

  • .eslintrc.js / .eslintrc.cjs - Javascipt形式 ( 値を動的に生成する場合はこれを選ぶ )
  • .eslintrc.json - JSON形式
  • .eslintrc.yml - YAML形式
  • .eslintrc - コメントの入れられるJSON形式のようだが非推奨のようだ

どの形式でもプロパティの構成は同じ

.eslintrc の生成

コマンドを使うと対話形式で作成してくれる。(選択肢が多い)

 npm create @eslint/config

ファイル形式を聞かれるステップがあるのでここで好きな形式を答えると良い

? What format do you want your config file to be in? …
❯ JavaScript
  YAML
  JSON

Javascriptファイル の例

module.exports = {
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended"
    ],
    "overrides": [
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": "latest",
        "sourceType": "module"
    },
    "plugins": [
        "@typescript-eslint"
    ],
    "rules": {
    }
}

JSONの例

{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended"
    ],
    "overrides": [
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": "latest",
        "sourceType": "module"
    },
    "plugins": [
        "@typescript-eslint"
    ],
    "rules": {
    }
}

YAML の例

env:
  browser: true
  es2021: true
extends:
  - eslint:recommended
  - plugin:@typescript-eslint/recommended
overrides: []
parser: '@typescript-eslint/parser'
parserOptions:
  ecmaVersion: latest
  sourceType: module
plugins:
  - '@typescript-eslint'
rules: {}

参考

1
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
1
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?