-
Notifications
You must be signed in to change notification settings - Fork 927
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
Add eslint support to presubmit checks #16289
Conversation
3ecbf13
to
eb12947
Compare
a4763a4
to
ced869f
Compare
716b67f
to
1a5ffa9
Compare
node_args = [ | ||
brave_node.PathInNodeModules('eslint', 'bin', 'eslint'), | ||
'--quiet', | ||
'--resolve-plugins-relative-to', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean we have to make sure we include any plugins used by upstream in our node modules? What are they currently missing that we need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it seems like we will because that eslint only applies to certain directories. Isn't there some way to specify additional plugin directories? Or can we make these relative paths? https://github.com/brave/brave-core/pull/16289/files#diff-57765a2557bc107c8e5ef5c7c256163c899314e0e7ad9ec7ba31d9f5188d0bafR69
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean we have to make sure we include any plugins used by upstream in our node modules? What are they currently missing that we need?
yes ideally we need to have all modules that upstream uses for their eslint
runs.
Currently we're missing only eslint-plugin-jsdoc
which is not used by the root src/.eslintrc.js
config, so I'm pretty sure we can ignore this until we want to use it on our own.
brave/components/.eslintrc.js
actually should not have 'root': true
, but currently we need this to gradually inherit upstream rules.
this is the list of upstream modules (located in src/third_party/node/package.json
):
{
"name": "webui-node-modules",
"version": "1.0.0",
"author": "[email protected]",
"dependencies": {
"@types/chai": "4.2.22",
"@types/d3": "5.16.0",
"@types/dom-mediacapture-record": "1.0.11",
"@types/dom-speech-recognition": "0.0.1",
"@types/filesystem": "0.0.32",
"@types/filewriter": "0.0.29",
"@types/google.analytics": "0.0.42",
"@types/mocha": "9.0.0",
"@types/offscreencanvas": "2019.6.4",
"@types/trusted-types": "1.0.6",
"@types/w3c-css-typed-object-model-level-1": "20180410.0.4",
"@types/w3c-image-capture": "1.0.4",
"@types/webrtc": "0.0.31",
"@typescript-eslint/eslint-plugin": "5.12.0",
"@typescript-eslint/parser": "5.12.0",
"babel-eslint": "10.0.2",
"eslint": "7.11.0",
"eslint-plugin-jsdoc": "37.5.1",
"html-minifier": "4.0.0",
"rollup": "2.58.0",
"svgo": "2.8.0",
"terser": "5.3.3",
"typescript": "4.6.3"
}
}
we have this (brave/package.json
):
"@typescript-eslint/eslint-plugin": "4.33.0",
...
"eslint": "7.32.0",
"eslint-config-standard-with-typescript": "21.0.1",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-jest": "25.2.2",
"eslint-plugin-licenses": "1.0.2",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.1.1",
eslint-config-standard-with-typescript
automatically includes @typescript-eslint/parser
, so we're missing only eslint-plugin-jsdoc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it seems like we will because that eslint only applies to certain directories. Isn't there some way to specify additional plugin directories? Or can we make these relative paths?
no, there's no way to use multiple directories for plugins. We need to update/add deps during Chromium rebase if eslint
will start to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see if I understand what this is doing:
- Moving current eslint config to components/ so that it only controls that directory
- Ignores upstream eslint for
ui/webui/components
- Ignores upstream eslint for
.storybook
Does that leave anything left to be lint with upstream's config? Maybe scripts in build/
?
If not, I would suggest that instead we keep eslintrc in the root because I don't think we ever want different styleguides within the same repo. Then, incrementally in subsequent PRs, modify the existing eslintrc incrementally to:
- include the
ui/webui/resources/
andbuild/
directories - be based on upstream's eslint (and standard?)
I'm still unclear if upstream's eslint rules can ever be compatible with our eslint config (might be many contradicting rules since ours is based on Standard). So would be good to separate including upstream's config to a separate PR until we figure that out. We'd never want a situation where we have separate competing rules in the same repo for different directories. I think consistency internal to this repo is more important than consistency with Chromium's repo. It can also be argued that consistency with other Brave TS repositories is more important than with Chromium since we largely use different frontend frameworks and filetypes than Chromium.
That is correct, but this is not the final state.
We absolutely shouldn't have different eslint rules in brave-core. The plan for this PR:
The next PR:
The additional PRs after that:
You can look at issues in
IMO brave-core should be seen and operated as the Chromium repo without distinction. |
Whilst this may be true for the C++, the situation is quite different for frontend code:
This PR as it stands is assuming we'll get rid of the Brave-style StandardJS rules in favor of the Google style guide. That's not decided across the company, and I think this PR needs to focus on integrating the current rules with presubmit, with a view that the next PRs:
|
7d8ef7a
to
f79211e
Compare
Okay, let's focus on integrating of presubmit checks in this PR, that's fine. But I'd like us to do the right thing during formatter integration and configure it in less error prone style from the start. It should solve all "semicolon and comma" issues automatically, so I don't see why we want to ignore this and just create another iteration in future. |
@@ -0,0 +1,120 @@ | |||
// Copyright (c) 2021 The Brave Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a compare and can confirm nothing has changed in this file apart from changing from JSON to JS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM too
7d5c8e8
to
a2559ed
Compare
a2559ed
to
e441f7c
Compare
This PR:
node
withbrave/node_modules
.npm run presubmit -- --fix
parameter to automatically pass it toeslint
and perform code formatting instead of dry-running to show errors (i.e. runsnpm run format
for you)..storybook/*
,build/*
,browser/*
,ui/webui/resources*
to the current eslint config.Resolves brave/brave-browser#27236
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: