How to run eslint in different folders

Viewed 1920

I came into a eslint problem. Generally, we have src folder side by side with package.json, like this:

|-projectName
  |- src
  |- .eslintrc.js
  |- package.json
  |- vue.config.js

Then i want to take compiling scripts and business code apart into different folders, and to enable them to be linted, i put two '.eslintrc.js' files in each, like this:

|- projectName
  |- runtime
    |- babel.config.js
    |- .eslintrc.js
    |- package.json
    |- vue.config.js
  |- business
    |- .eslintrs.js
    |- src
      |- main.js
      |- index.html
      |- ...

Then i found eslint turns into chaos: When i ran 'npm run build', eslint firstly linted files in 'runtime' folder as '.eslintrc.js' in it,

and then vue-cli-service came into building stage, which called eslint again as '.eslintrc.js' in 'template' folder,

but at last the vue-cli-service still finished building even if eslint throws errors, which should stopped building. The output was like this:

āœ– 7 problems (4 errors, 3 warnings)
  3 errors and 3 warnings potentially fixable with the `--fix` option.

 @ ../template/src/store/index.js 14:0-34 18:10-14
 @ ../template/src/main.js
 @ multi ../template/src/main.js

...

  File                                      Size             Gzipped

  ../template/build/apps/local/0/js/chun    174.42 KiB       58.47 KiB
  k-vendors.9db3f582.js
...

 DONE  Build complete. The ../template/build directory is ready to be deployed.
 INFO  Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html

I don't know why this happened? Is there someting wrong with eslint config? I just put two '.eslintrc.js' files generated by 'vue craete' command in two different folders , and configure right paths in vue.config.js, like this:

// vue.config.js
...
outputDir: path.resolve(__dirname, '../template/build'),
pages:{
  index: {
    entry: path.resolve(__dirname, '../template/src/main.js')
  }
}
...
0 Answers
Related