首页 > 解决方案 > Github 操作抛出 eslint 错误但在本地构建成功

问题描述

我是 Github 操作的新手。我正在尝试通过 Github Action 将我的 Vue.js 项目部署到 Azure 静态 Web 应用程序。

部署时会引发 eslint 错误,但是当我在 Windows 上本地执行 eslint fix 时,它说没有什么可修复的。该项目几乎是全新的,只是添加了一些额外的设置(包括换行设置),这是我的eslint设置。

module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: [
    'plugin:vue/essential',
    '@vue/airbnb',
  ],
  parserOptions: {
    parser: 'babel-eslint',
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'eol-last': 0,
    'linebreak-style': ['error', 'windows'],
    "indent": [2, 2],
  },
};

我读了这篇文章,我正在使用airbnb设置,但应该没有问题,因为我用'linebreak-style'覆盖规则:['error','windows']?

https://github.com/airbnb/javascript/pull/1224

Current runner version: '2.273.5'
Operating System
  Ubuntu
  18.04.5
  LTS
...
messageboard@0.1.0 build /github/workspace
vue-cli-service build

-  Building for production...
 ERROR  Build failed with errors.
 ERROR  Failed to compile with 7 errors2:31:51 PM

 error  in ./src/App.vue

Module Error (from ./node_modules/eslint-loader/index.js):

/github/workspace/src/App.vue
   1:11  error  Expected linebreaks to be 'CRLF' but found 'LF'  linebreak-style
   2:17  error  Expected linebreaks to be 'CRLF' but found 'LF'  linebreak-style
   3:19  error  Expected linebreaks to be 'CRLF' but found 'LF'  linebreak-style

有关整个错误日志,请参阅:https ://github.com/simari1/MessageBoard/runs/1231832137?check_suite_focus=true

问题似乎是我的电脑是 Windows 但构建服务器是 Ubuntu?我缺少一些设置吗?

到目前为止我尝试了什么:

先感谢您。

标签: eslintgithub-actions

解决方案


推荐阅读