带有ESLint --init的GitLab CI在输入提示时失败

时间:2019-04-11 20:15:16

标签: continuous-integration gitlab eslint

我遵循instructions in this post在GitLab CI中设置ESLint。之所以失败,是因为初始化期间ESLint停止询问问题...

Skipping Git submodules setup
$ npm install -g eslint
/usr/local/bin/eslint -> /usr/local/lib/node_modules/eslint/bin/eslint.js
+ eslint@5.16.0
added 117 packages from 70 contributors in 7.16s
$ eslint --init
? How would you like to use ESLint? (Use arrow keys)
  To check syntax only 
❯ To check syntax and find problems 
  To check syntax, find problems, and enforce code style ERROR: Job failed: exit code 1

我的存储库根目录中确实有一个.eslintrc文件。我如何解决导致管道失败的提示/问题?谢谢!

1 个答案:

答案 0 :(得分:1)

如果存储库的根目录中已经有一个.eslintrc文件,则无需再次进行设置。我遵循了相同的说明,并且对此问题感到烦恼,直到我评论了--init行。这是我的ESLint任务,仅供参考:

eslint:
  <<: *exclude_tags
  stage: lint
  image: node
  tags:
    - web
  before_script:
    - call npm i -g eslint-cli
    - call npm i eslint --save-dev
    - call npm i @typescript-eslint/parser --save-dev
    - call npm i @typescript-eslint/eslint-plugin --save-dev
    - call npm i eslint-plugin-security --save-dev
  script:
    - node node_modules\eslint\bin\eslint.js --ext .js,.jsx,.ts,.tsx src/
  allow_failure: true