Skip to content
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

lint: switch to using eslint directly #827

Merged
merged 7 commits into from
May 9, 2024

Conversation

alxndrsn
Copy link
Contributor

@alxndrsn
Copy link
Contributor Author

alxndrsn commented Jul 12, 2023

For me this cuts repeated lint run duration from ~25s to <2s.

@matthew-white
Copy link
Member

matthew-white commented Jul 12, 2023

For me this cuts repeated lint run duration from ~25s to <2s.

I've also been noticing that linting has been pretty slow lately. Cutting down the duration like this would be a big win.

vue-cli-service is deprecated

Hoping to move to Vite (#671) before too long!

using eslint directly is recommended for vue 3 see: https://cli.vuejs.org/core-plugins/eslint.html see: https://vuejs.org/guide/scaling-up/tooling.html#linting

Are you sure this doesn't require Vite? Before listing recommendations, the second link says:

when using a Vite-based build setup, our general recommendation is:

Can you tell whether .vue files are still being linted?

  • Are templates being linted? For example, if you remove <!-- eslint-disable vue/no-v-html --> from src/components/collect-qr.vue, does ESLint display an error?
  • Is the JS in <script> tags being linted?

* this allows the use of the --cache flag for faster repeated linting (not
  supported in `vue-cli-service lint`)
  see: https://cli.vuejs.org/core-plugins/eslint.html#injected-commands
* `vue-cli-service` is deprecated, and using `eslint` directly is recommended
  for vue 3
  see: https://cli.vuejs.org/core-plugins/eslint.html
  see: https://vuejs.org/guide/scaling-up/tooling.html#linting
@alxndrsn
Copy link
Contributor Author

alxndrsn commented Sep 6, 2023

Are you sure this doesn't require Vite?

I don't think this PR has added Vite, and it seems to work 🤔

Can you tell whether .vue files are still being linted?

  • Are templates being linted? For example, if you remove <!-- eslint-disable vue/no-v-html --> from src/components/collect-qr.vue, does ESLint display an error?

  • Is the JS in <script> tags being linted?

Yes & yes - check out this failing build: https://app.circleci.com/pipelines/github/getodk/central-frontend/1502/workflows/2554db3f-f934-4df5-88c3-267572382cc1/jobs/1816

> [email protected] lint
> eslint --cache --no-fix --max-warnings 0 --ext .js,.vue src/ bin/ test/ *.js


/home/circleci/repo/src/components/account/claim.vue
  41:42  error  Missing semicolon  semi

/home/circleci/repo/src/components/collect-qr.vue
  14:28  warning  'v-html' directive can lead to XSS attack  vue/no-v-html

✖ 2 problems (1 error, 1 warning)
  1 error and 0 warnings potentially fixable with the `--fix` option.


Exited with code exit status 1

@matthew-white
Copy link
Member

I'm in the process of moving from Vue CLI to Vite (#671). As mentioned above, under Vite, eslint is used directly, so we're about to be moving in the direction of this PR anyway. Given that linting continues to work with the changes here, I think we should try to get this PR merged. There's a conflicting file, but I can resolve that now.

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
@@ -31,7 +31,6 @@ module.exports = {
css: { url: false }
}
},
lintOnSave: false,
Copy link
Member

Choose a reason for hiding this comment

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

This looks to be an option of the ESLint plugin for Vue CLI, so I think we can remove it. From https://cli.vuejs.org/core-plugins/eslint.html#configuration:

The following option is under the section of vue.config.js. It is respected only when @vue/cli-plugin-eslint is installed.

Copy link
Member

@matthew-white matthew-white left a comment

Choose a reason for hiding this comment

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

I think this PR is ready to merge, so I'm going to go ahead and approve and merge. I've made some changes myself, though nothing big. @alxndrsn, it'd be great if you could take a look at my changes once you have the chance just to confirm that they make sense.

@matthew-white matthew-white merged commit 18159e7 into getodk:master May 9, 2024
1 check passed
@matthew-white matthew-white mentioned this pull request May 9, 2024
@alxndrsn alxndrsn deleted the faster-lint branch May 9, 2024 15:22
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