НПМ и Эслинт: Это сбивает с толку, это нормально? - PullRequest
0 голосов
/ 26 октября 2018

Я новичок в JS и пытаюсь научиться линтингу.Итак, я следую руководству, в котором мы устанавливаем этап lint в файле package.json.

Это выглядит так: "lint": "./node_modules/.bin/eslint ."

Так что в терминале, когда я запускаю./node_modules/.bin/eslint . сообщает обо всех ошибках и предупреждениях, что приятно, как и ожидалось.

/Users/me/dev/webapps/templates/sample_node_project/index.js
  1:1   error    Expected 1 empty line after require statement not followed by another require  import/newline-after-import
  1:35  error    Missing semicolon                                                              semi
  5:27  error    Missing semicolon                                                              semi
  9:3   warning  Unexpected console statement                                                   no-console
  9:53  error    Missing semicolon                                                              semi

✖ 5 problems (4 errors, 1 warning)
  4 errors and 0 warnings potentially fixable with the `--fix` option.

Но когда я запускаю npm run lint, я получаю следующее:

/Users/me/dev/webapps/templates/sample_node_project/index.js
  1:1   error    Expected 1 empty line after require statement not followed by another require  import/newline-after-import
  1:35  error    Missing semicolon                                                              semi
  5:27  error    Missing semicolon                                                              semi
  9:3   warning  Unexpected console statement                                                   no-console
  9:53  error    Missing semicolon                                                              semi

✖ 5 problems (4 errors, 1 warning)
  4 errors and 0 warnings potentially fixable with the `--fix` option.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sample_node_project@1.0.0 lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sample_node_project@1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2018-10-25T23_15_56_180Z-debug.log

Это приводит к дополнительному блоку ошибок, из-за чего я думаю, что мои node и npm повреждены.Кроме того, в этом уроке инструктор запускает yarn lint, и он, похоже, получает намного меньше этого дополнительного блока ошибок.

Это нормально?

1 Ответ

0 голосов
/ 26 октября 2018

npm run lint -s подавит ошибку NPM, которую вы видите.ESLint дает ненулевой код выхода из-за ошибок lint.NPM в основном говорит, что он не может работать правильно из-за ошибок linting.Так что да, это нормально.

...