Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9134

ESLintをディレクトリ以下にインストールして使用する

$
0
0
概要 nodeJSをインストールしてからESLineを使用できるようになるまでの設定方法 ESLineはグローバルにインストールするのではなく作業ディレクトリ以下にインストールする 環境 macOS Big Sur node 14.18.0 npm 6.14.15 設定方法 ディレクトリの準備 $ mkdir node_test $ cd node_test package.json を作成する npm init して適宜設定していく $ npm init ESLint のインストール eslint の本体は作業環境にインストールする ( -D | --save-dev ) node_modules/.bin/eslint にリンクが生成される 実体は node_modules/eslint/bin/eslint.js にインストールされる $ npm install eslint --save-dev ESLint の設定をする 対話形式で設定を行う $ node_modules/.bin/eslint --init enforce code style を含めて Use a popular style guide にすると ? How would you like to use ESLint? … To check syntax only To check syntax and find problems ❯ To check syntax, find problems, and enforce code style ? How would you like to define a style for your project? … ❯ Use a popular style guide どのスタイルガイドを使用するか選択する この時に選択したスタイルガイドの設定がインストールされていない場合にはインストールする ? Which style guide do you want to follow? … Airbnb: https://github.com/airbnb/javascript Standard: https://github.com/standard/standard ❯ Google: https://github.com/google/eslint-config-google XO: https://github.com/xojs/eslint-config-xo Checking peerDependencies of eslint-config-google@latest The config that you've selected requires the following dependencies: eslint-config-google@latest eslint@>=5.16.0 ? Would you like to install them now with npm? › No / Yes 実行 ファイルを作成 main.js console.log("Hello World!!") ESLint の実行 ( テストのみ ) $ node_modules/.bin/eslint main.js ***/node_test/main.js 1:13 error Strings must use singlequote quotes 1:29 error Missing semicolon semi ✖ 2 problems (2 errors, 0 warnings) 2 errors and 0 warnings potentially fixable with the `--fix` option. ESLint の実行 ( 上書きも ) $ node_modules/.bin/eslint --fix main.js main.js console.log('Hello World!!');

Viewing all articles
Browse latest Browse all 9134

Trending Articles