From fedae9e81f7c49d0adf489658fde475536220734 Mon Sep 17 00:00:00 2001 From: Graham Johnson Date: Fri, 9 Feb 2024 08:02:41 -0800 Subject: [PATCH] Clean up linter scripts and docs (#6457) * Clean up linter scripts and docs * Swap lint scripts from accidental deletion --- knowledge_base/Linting.md | 4 +--- knowledge_base/Package-Scripts.md | 19 +++---------------- package.json | 1 - packages/commonwealth/package.json | 1 - scripts/lint-new-work.sh | 9 --------- 5 files changed, 4 insertions(+), 30 deletions(-) delete mode 100755 scripts/lint-new-work.sh diff --git a/knowledge_base/Linting.md b/knowledge_base/Linting.md index 3ab8403b744..aca1d69a4d5 100644 --- a/knowledge_base/Linting.md +++ b/knowledge_base/Linting.md @@ -12,12 +12,10 @@ All linting commands should be run from root. -- `yarn lint` - - Lints new code changes that have yet to be committed. - `yarn lint-all` - Lints all code (regardless of changes) - `yarn lint-branch` - - Lints all changes made in a branch (used in CI). This is the command most people will want to use. + - Lints all changes made in a branch (used in CI). ## Configuration diff --git a/knowledge_base/Package-Scripts.md b/knowledge_base/Package-Scripts.md index a27c99c5f20..c952b1a5e7c 100644 --- a/knowledge_base/Package-Scripts.md +++ b/knowledge_base/Package-Scripts.md @@ -33,7 +33,6 @@ If you add a script to the `package.json` file, please add documentation for it - [cosmos:stop](#cosmosstop) - [Linting & Formatting](#linting--formatting) - [format](#format) - - [lint](#lint) - [lint-all](#lint-all) - [lint-branch](#lint-branch) - [lint-branch-warnings](#lint-branch-warnings) @@ -241,29 +240,17 @@ Definition: `prettier --ignore-path ../../.prettierignore --config ../../.pretti Description: Autoformats files using config `prettierrc.json` config. -### lint - -Definition: `./scripts/lint-new-work.sh` - -Description: Lints new work, according to script file `lint-new-work.sh`. - -Considerations: Problematically, only checks .ts files. Name is misleading. Redundancy with [lint-branch](#lint-branch) script. **Flagged for possible removal.** - ### lint-all Definition: `eslint client/\\**/*.{ts,tsx} server/\\**/*.ts` -Description: Only lints changed files on current branch. - -Considerations: May be more clearly renamed "lint-changes". +Description: Lints all TypeScript files within the `client` and `server` directories. ### lint-branch Definition: `./scripts/lint-branch.sh` -Description: Redundant with [lint](#lint) script, which uses 'git status' instead of 'git diff' but is build toward the same action (isolating changed files for linting). - -Considerations: Recommend eliminating either [lint](#lint) or [lint-branch](#lint-branch) scripts. Problematically, lint-branch only checks .ts files. **Flagged for possible removal.** +Description: Used in the CI. Lints updated files on the current branch. ### lint-branch-warnings @@ -277,7 +264,7 @@ Definition: `stylelint client/styles/*` Description: Lints SCSS files. -Considerations: Why lint styles separately? Why not just include `.scss` file extension in [lint](#lint) and [lint-all](#lint-all) scripts (which currently only target `.ts` files)? **Flagged for possible removal.** +Considerations: Why lint styles separately? Why not just include `.scss` file extension in [lint-branch](#lint-branch) and [lint-all](#lint-all) scripts (which currently only target `.ts` files)? **Flagged for possible removal.** ## Other services diff --git a/package.json b/package.json index 6e58fa0dbaf..9f5f1207859 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "format-check": "prettier --check .", "heroku-postbuild": "chmod u+x scripts/heroku-build.sh && ./scripts/heroku-build.sh", "heroku-prebuild": "yarn global add node-gyp", - "lint": "./scripts/lint-new-work.sh", "lint-all": "NODE_OPTIONS=\"--max-old-space-size=4096\" eslint './packages/**/*.{ts,tsx}'", "lint-branch": "./scripts/lint-branch.sh", "lint-branch-warnings": "FAIL_WARNINGS=1 ./scripts/lint-branch.sh", diff --git a/packages/commonwealth/package.json b/packages/commonwealth/package.json index 84eee36dd44..20d89e1c628 100644 --- a/packages/commonwealth/package.json +++ b/packages/commonwealth/package.json @@ -20,7 +20,6 @@ "format": "prettier --ignore-path ../../.prettierignore --config ../../.prettierrc.json --write .", "heroku-postbuild": "NODE_OPTIONS=--max-old-space-size=$(../../scripts/get-max-old-space-size.sh) webpack --config webpack/webpack.prod.config.js --progress && yarn build-consumer", "integration-test": "nyc ts-mocha -r tsconfig-paths/register './test/integration/**/*.spec.ts'", - "lint": "./scripts/lint-new-work.sh", "lint-all": "eslint client/\\**/*.{ts,tsx} server/\\**/*.ts", "lint-branch": "./scripts/lint-branch.sh", "listen": "RUN_AS_LISTENER=true ts-node -r tsconfig-paths/register server.ts", diff --git a/scripts/lint-new-work.sh b/scripts/lint-new-work.sh deleted file mode 100755 index 4329d8a9af9..00000000000 --- a/scripts/lint-new-work.sh +++ /dev/null @@ -1,9 +0,0 @@ -LINES=$(git status --porcelain | grep "/*.ts" | sed 's/^...//' | tr '\n' ' ' | xargs ls -d 2>/dev/null) - -if [ -z "$LINES" ] -then - echo "There is nothing to lint" -else - echo $LINES - NODE_OPTIONS="--max-old-space-size=4096" eslint $LINES -fi