Skip to content

Commit

Permalink
chore: improve/decouple eslint and tsc 'npm run' commands (apache#26704)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 24, 2024
1 parent 7c2093c commit 0f59079
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ jobs:
uses: ./.github/actions/cached-dependencies
with:
run: npm-install
- name: lint
- name: eslint
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: |
npm run eslint -- . --quiet
- name: tsc
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: |
npm run type
- name: prettier
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: |
npm run lint -- --quiet
npm run prettier-check
- name: Build plugins packages
if: steps.check.outcome == 'failure'
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/superset-websocket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ jobs:
- name: Install dependencies
working-directory: ./superset-websocket
run: npm ci
- name: lint
- name: eslint
working-directory: ./superset-websocket
run: npm run lint
run: npm run eslint -- .
- name: typescript checks
working-directory: ./superset-websocket
run: npm run type
- name: prettier
working-directory: ./superset-websocket
run: npm run prettier-check
Expand Down
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,10 @@ is configured as a pre-commit hook. There are also numerous [editor integrations
```bash
cd superset-frontend
npm ci
npm run lint
# run eslint checks
npm run eslint -- .
# run tsc (typescript) checks
npm run type
```

If using the eslint extension with vscode, put the following in your workspace `settings.json` file:
Expand Down
5 changes: 4 additions & 1 deletion docs/docs/contributing/hooks-and-linting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ is configured as a pre-commit hook. There are also numerous [editor integrations
```bash
cd superset-frontend
npm ci
npm run lint
# run eslint checks
npm run eslint -- .
# run tsc (typescript) checks
npm run type
```

If using the eslint extension with vscode, put the following in your workspace `settings.json` file:
Expand Down
3 changes: 2 additions & 1 deletion superset-frontend/js_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ cd "$(dirname "$0")"
npm --version
node --version
time npm ci
time npm run lint
time npm run eslint -- .
time npm run check
time npm run cover # this also runs the tests, so no need to 'npm run test'
time npm run build
6 changes: 3 additions & 3 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"src/setup/*"
],
"scripts": {
"_lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,tsx .",
"_prettier": "prettier './({src,spec,cypress-base,plugins,packages,.storybook}/**/*{.js,.jsx,.ts,.tsx,.css,.less,.scss,.sass}|package.json)'",
"build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 NODE_ENV=production BABEL_ENV=\"${BABEL_ENV:=production}\" webpack --mode=production --color",
"build-dev": "cross-env NODE_OPTIONS=--max_old_space_size=8192 NODE_ENV=development webpack --mode=development --color",
Expand All @@ -50,9 +49,10 @@
"cover": "cross-env NODE_ENV=test jest --coverage",
"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",
"eslint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,tsx",
"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",
"lint-fix": "npm run eslint -- . --fix",
"plugins:build": "node ./scripts/build.js",
"plugins:build-assets": "node ./scripts/copyAssets.js",
"plugins:build-storybook": "cd packages/superset-ui-demo && npm run build-storybook",
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function getPackages(packagePattern, tsOnly = false) {
let scope = getPackages(glob);

if (shouldLint) {
run(`npm run lint --fix {packages,plugins}/${scope}/{src,test}`);
run(`npm run eslint -- . --fix {packages,plugins}/${scope}/{src,test}`);
}

if (shouldCleanup) {
Expand Down

0 comments on commit 0f59079

Please sign in to comment.