Problem/Motivation
The Eslint configuration is set up with only a few rules at the moment. This means it's not catching things like:
- Comments well over 80 chars
- Inconsistency in single vs double quotes
- Inconsistency in lines ending with semi colons
- Inconsistency in trailing commas
Obviously none of these things are bad and we're still in rapid iteration mode, but to save us pain in the future I think it's worth setting up some rules now.
Steps to reproduce
Review the codebase
Proposed resolution
Add the following to eslintrc
In extends, add "plugin:prettier/recommended". We already have this installed
Add some basic prettier rules
"prettier/prettier": ["error", {
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid",
}],Set max line length and brace-style
"max-len": "error",
"brace-style": ["error", "stroustrup"]Alternatively, if we wanted to go even further we could embrace cores eslint, which is even more strict
Remaining tasks
Add changes to MR (Incoming)
Agree on approach
Fix the lint issues introduced as part of this MR
Merge
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Issue fork experience_builder-3452828
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
danielvezaComment #5
wim leersThanks, @DanielVeza! Excited to see you here! 😄
Per @larowlan, we should first land #3450307: CI: use template's `eslint` job to validate YML and JS, add new `UI eslint` job for UI's TypeScript to avoid the need to redo this in the future.
Comment #6
wim leers#3450307: CI: use template's `eslint` job to validate YML and JS, add new `UI eslint` job for UI's TypeScript is in, meaning this is now unblocked!
Comment #10
gauravvvv commentedComment #11
finnsky commentedI've found MR contains some unexpected changes.
Like src/App.tsx
Also lint:fix show failures.
Comment #12
finnsky commentedComment #13
finnsky commentedI also see existing `"format": "prettier --write .",` task in package.json
Should we keep it?
Comment #16
finnsky commentedI've created new PR.
- It should only affect js changes.
- We need to create follow up issue for stylelint and yaml etc. Because current `npm run format` still fixes public and MD and CSS files.
Comment #18
bnjmnmThere were some pipeline failures that I was looking into only to re-run the tests and they were fine. In each case it was because the project directory could not be found, something that would not be caused by changes in either of the merge requests.
While I'm partial to the @finnsky MR #78 because it only changes the JS, the
npm run formatcommand still runs on non-js files. This means someone wanting to useformatwill have files changed that they haven't even edited. We should either include all file types or limit the types changed byformatComment #19
wim leers@finnsky: Could you address #18? 😊 🙏 Would love to see this land!
Comment #20
finnsky commentedI have weird deja vu :)
https://www.drupal.org/project/drupal/issues/3409048#comment-15525622
Linter issues aren't rebase friendly.
I will reapply changes in new 0.x based branch and let's create followup for CSS and MD
Comment #22
finnsky commentedComment #23
lauriiiComment #24
wim leers#20: hah!
I'm fine with doing additional things in follow-ups, but would like to see @bnjmnm's feedback in #18 addressed. That doesn't require Doing All The Things in this issue — an alternative can be to restrict what
npm run formatdoes. Could you do that, @finnsky? 🤞Comment #25
finnsky commentedRemoved format for now. We need to configure linter + prettier for css and other files.
Comment #26
finnsky commentedComment #27
wim leers@bnjmnm you did the last round of review for this in #18 — could you give this another pass? 🙏
Comment #29
bnjmnmNot sure that's a good idea either - if GitlabCI + eslint is enforcing prettier formatting, we shouldn't require contributors to fix all of those things manually when a formatter is right there I think it's best to go with my suggestion in #18 and have the formatter only act on JS files for the time being, while also configuring ESLint to enforce prettier formatting. That's what I have in the
<a href="https://git.drupalcode.org/project/experience_builder/-/merge_requests/124#note_349548">3452828-js-only-eslint-with-format </a>MRComment #32
bnjmnmComment #33
wim leersOMG YES! So glad this is in! 😄👍