Skip to content

Fix documentation on default linted files #6199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 13, 2021

Conversation

Robin-Hoodie
Copy link
Contributor

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

The documentation mentions all files in the src and tests directories are linted by default. Upon inspection of the sourcecode however, it seems that also Javascript files in the root directory are being linted by default.

I stumbled upon this when trying to figure out why my .eslintrc.js file itself was being linted by running vue-cli-service lint without passing any args.

The documentation mentions all files in the `src` and `tests` directories are linted by default. Upon inspection of the [sourcecode](https://github.com/vuejs/vue-cli/blob/3eaef4d388c52ea1d698991e7e96497164f90a04/packages/%40vue/cli-plugin-eslint/lint.js#L55) however, it seems that also Javascript files in the root directory are being linted by default.

I stumbled upon this when trying to figure out why my `.eslintrc.js` file itself was being linted by running `vue-cli-service lint` without passing any args.
Copy link
Collaborator

@fangbinwei fangbinwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.*.js like .eslintrc.js will be linted only if there is no .eslintignore in project according to

if (!fs.existsSync(api.resolve('.eslintignore')) && !config.ignorePattern) {
.Maybe it's not worth mentioning ?

If .eslintignore exists and we want to lint .eslintrc.js, !.*.js should be added to .eslintignore

@Robin-Hoodie
Copy link
Contributor Author

Robin-Hoodie commented Jan 11, 2021

I wasn't aware dot-files were not being linted by default by ESLint. I also wasn't aware that the default behaviour of vue-cli-service lint is to override that default behavior of ESLint.

Perhaps it's best to mention both behaviours then?

Something along the lines of:

vue-cli-service lint will by default lint hidden dot-files if there is no .eslintignore file or ignorePatterns property in your ESLint config. This behaviour is in contrast to ESLint's default behaviour, which will not lint dot-files by default. If you want to follow ESLint's default behaviour instead, consider adding an (empty) .eslintignore file or any ignorePatterns property to your ESLint config file

Copy link
Collaborator

@fangbinwei fangbinwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer not to describe the default behavior of ESlint, which may change. ESlint@7 no longer ignores .eslintrc.js,

:::tip
`vue-cli-service lint` will lint dotfiles `.*.js` by default. If you want to follow ESLint's default behavior instead, consider adding a `.eslintignore` file in your project.
:::

Add a tip to make users aware of `@vue/cli-plugin-eslint` overriding default ESLint behavior
Copy link
Collaborator

@fangbinwei fangbinwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot

@fangbinwei fangbinwei merged commit 8f1324c into vuejs:master Jan 13, 2021
@Robin-Hoodie Robin-Hoodie deleted the patch-1 branch January 13, 2021 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants