LoginSignup
0
0

More than 3 years have passed since last update.

eslint install (linter to js)

Last updated at Posted at 2020-05-06

Installation and Usage

Prerequisites: Node.js (^8.10.0, ^10.13.0, or >=11.10.1) built with SSL support. (If you are using an official Node.js distribution, SSL is always built in.)
前提条件:Node.js() SSLが支援しているものでビルドされているもの(普通公式サイトで配布されているNode.jsを使ったら、その中でSSLは入っているはず)

You can install ESLint using npm:
npmを利用してESLintをセットアップしましょう

$ npm install eslint --save-dev
You should then set up a configuration file:
image.png

$ ./node_modules/.bin/eslint --init
After that, you can run ESLint on any file or directory like this:
image.png
なんか選べる~~

$ ./node_modules/.bin/eslint yourfile.js

拡張(Extensions)セットアップ

eslint-plugin-prettier
https://github.com/prettier/eslint-plugin-prettier

In addition to the above installation instructions, install eslint-config-prettier:

npm install --save-dev eslint-config-prettier
Then you need to add plugin:prettier/recommended as the last extension in your .eslintrc.json:

{
  "extends": ["plugin:prettier/recommended"]
}

This does three things:

Enables eslint-plugin-prettier.
Sets the prettier/prettier rule to "error".
Extends the eslint-config-prettier configuration.
You can then set Prettier's own options inside a .prettierrc file.

In order to support special ESLint plugins (e.g. eslint-plugin-react), add extra exclusions for the plugins you use like so:

{
  "extends": [
    "plugin:prettier/recommended",
    "prettier/flowtype",
    "prettier/react",
    "prettier/standard"
  ]
}

For the list of every available exclusion rule set, please see the readme of eslint-config-prettier.

0
0
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
0