Problem/Motivation
ESLint was failing with the following errors:
$ $CI_PROJECT_DIR/$_WEB_ROOT/core/node_modules/.bin/eslint --no-error-on-unmatched-pattern --ignore-pattern="*.es6.js" --resolve-plugins-relative-to=$CI_PROJECT_DIR/$_WEB_ROOT/core --ext=.js,.yml . || true
Oops! Something went wrong! :(
ESLint: 8.55.0
ESLint couldn't find the config "airbnb-base" to extend from. Please check that the name of the config is correct.
The config "airbnb-base" was referenced from the config file in "/builds/issue/project_browser-3415079/web/modules/custom/project_browser-3415079/sveltejs/.eslintrc.js".
If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.
Steps to reproduce
Enable ESLint in .gitlab-ci.yml. Observe failure in pipeline.
Proposed resolution
I think the problem might be due to Svelte components not being installed. Going to try to add yarn commands to before script.
Comments
Comment #3
lostcarpark commentedI haven't managed to get the regular "eslint" check to validate the Svelte code. This could be because it's tailored to validate Drupal style JS.
I've set up a separate "sveltejs-eslint" job to run the existing
yarn lint:sveltecommand from DrupalCI, and it's working correctly.My thinking is we use the regular "eslint" job to only validate non-Svelte JS. I was looking for a way to exclude the directory. The only way I've found to add
rm sveltejsto the before script. This seems a little hacky, but is okay since the whole environment is discarded after the validation job completes.I don't think we were validating the project_browser.admin.js file previously. We're now finding errors in that, but I think that should be a follow on issue.
Comment #5
fjgarlin commentedI tried the approach with
.eslintignorebut it didn't work, so reverted back to what @lostcarpark initially did, which I think it's also ok.The only really small change I did was to change the name of the job from "svelte-eslint" to "eslint-svelte" so it would appear right next to the "eslint" job in the pipelines (alphabetical order).
Given that that was my only change, I'm marking this RTBC.
PS: unrelated to this issue. If we have GitLab CI in such a good state already, do we need DrupalCI for the project at all?
Comment #7
chrisfromredfinRebased and ESLint is running, but now there's 8 warnings and 1 error that should be fixed, and that's progress!
Comment #8
lostcarpark commentedI have been fixing errors reported by ESLint. Changes are as follows:
++operator, so code using it has been expanded to make clearer.There is one reported issue that I don't know how to resolve:
tableDrag.rowObject = new tableDrag.row(row[0]);is reporting "A constructor name should not start with a lowercase letter". I'm sure what to do about this since the constructor is defined in a library.
Comment #9
lostcarpark commentedTo fix the last ESLint error, I changed from:
tableDrag.rowObject = new tableDrag.row(row[0]);to
This creates a new reference to the tableDrag.row class with a properly capitalized name. Effectively, this tricks ESLint into believing the constructor is correctly capitalized.
I've done some manual testing, and it seems to be working correctly. All tests are passing.
Comment #10
lostcarpark commentedAfter discussing with @chrisfromredfin, changed to the following:
Comment #11
lostcarpark commentedComment #12
chrisfromredfinQuick review is wonderful; just need clarity on one question/comment.
Comment #13
lostcarpark commentedPlease also see @fjgarlin's comment #5 above.
Comment #15
chrisfromredfinLet there be linting!