-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
chore: improve/decouple eslint and tsc 'npm run' commands #26704
chore: improve/decouple eslint and tsc 'npm run' commands #26704
Conversation
superset-frontend/package.json
Outdated
@@ -37,7 +37,7 @@ | |||
"src/setup/*" | |||
], | |||
"scripts": { | |||
"_lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,tsx .", | |||
"eslint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,tsx", |
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.
killing _lint
with a simple eslint
command with the parameters that should always be used, but importantly removing that .
at the end that prevents using this construct to run a specific folder of file. Since _lint
is implicitely "private" given the underscore, I thought is was ok to just remove it.
@@ -51,8 +51,8 @@ | |||
"dev": "webpack --mode=development --color --watch", | |||
"dev-server": "cross-env NODE_ENV=development BABEL_ENV=development node --max_old_space_size=4096 ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --mode=development", | |||
"format": "npm run _prettier -- --write", | |||
"lint": "npm run _lint && npm run type", | |||
"lint-fix": "npm run _lint -- --fix && npm run type", | |||
"lint": "npm run eslint -- . && npm run type", |
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.
maintaining backward compatibility, though I think we should deprecate eventually as it's unclear that you're running two commands here, and arguably tsc
isn't really linting.
"lint": "npm run _lint && npm run type", | ||
"lint-fix": "npm run _lint -- --fix && npm run type", | ||
"lint": "npm run eslint -- . && npm run type", | ||
"lint-fix": "npm run eslint -- . --fix", |
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.
same here, maintaining backward compat
@@ -36,11 +36,20 @@ jobs: | |||
uses: ./.github/actions/cached-dependencies | |||
with: | |||
run: npm-install | |||
- name: lint | |||
- name: eslint |
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.
breaking down the steps in CI makes it more clear where the output is coming from, and gets timing info on the different steps. Helping understand the time it takes for each step
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #26704 +/- ##
=======================================
Coverage 69.48% 69.48%
=======================================
Files 1894 1894
Lines 74138 74138
Branches 8243 8243
=======================================
Hits 51515 51515
Misses 20554 20554
Partials 2069 2069
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -20,6 +20,7 @@ cd "$(dirname "$0")" | |||
npm --version | |||
node --version | |||
time npm ci | |||
time npm run lint | |||
time npm run eslint -- . |
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.
Why is -- .
needed here and not for TypeScript?
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.
--
from my understanding is a npm run
feature where it allows you to pass arguments to the underlying command. npm will basically concatenate what's on the right of --
with the script / string you define. The way it was before where npm run lint
would wrap two commands, and with npm run _lint
it would specify the .
, so there was no way to use these pre-made scripts and "overload" your own arguments on top of the predefined ones.
In this case, I designed the npm run eslint
to not include the .
like it did before, so that a user that knows these conventions could run npm run eslint -- myfile.js
or npm run eslint -- --fix .
.
About the question about the .
not being needed for tsc, it's just that somehow npm run type
script is tsc --noEmit
, it doesn't require a file argument like eslint does.
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.
Thanks for this!
SUMMARY
I was having issues running just
tsc
oreslint
using ournpm run
scripts inpackage.json
, because of the way they were set up. Comment line-per-line in the PR here.npm run
commands