From b6e973638aa152c553ca4be5ceacc1e7a1f4081e Mon Sep 17 00:00:00 2001 From: Maxim Tsoy Date: Fri, 6 Dec 2024 14:09:19 +0100 Subject: [PATCH 1/2] Improve lint workflow --- .github/workflows/checks.yml | 2 +- CONTRIBUTING.md | 8 ++++++-- package.json | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f509bba238..2cbece1e49 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,7 +15,7 @@ jobs: node-version: 20 cache: 'npm' - run: npm run install-ci - - run: npm run lint + - run: npm run lint && echo 'No lint issues!' || (npm run lint-fix; git diff; echo 'Lint check failed, review diff above or run "npm run lint-fix"'; return 1) build: strategy: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f00e878ce9..01e9ef4cf1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -107,10 +107,14 @@ The extension imports several DDG-owned modules (see [package.json](https://gith ### Linting - All linting: `npm run lint` - - This includes both the ESLint and TypeScript checks. + - This includes the ESLint and TypeScript checks as well as Prettier style checks. + - To auto-fix all lint issues: `npm run lint-fix` - ESLint linting: `npm run eslint` - - To automatically fix mistakes found (where possible) use: `npm run eslint-fix` + - To automatically fix mistakes found (where possible) use: `npm run lint-fix` - TypeScript Linting: `npm run tsc` +- Prettier linting: `npm run prettier` + - To automatically fix style issues use: `npm run prettier-fix` + - Since Prettier rules are stylistic-only, it is okay to add `// prettier-ignore` comments to ignore specific lines or blocks of code. ### Testing - Unit tests: `npm test` (full docs [here](./unit-test/README.md)) diff --git a/package.json b/package.json index b03dc67058..07ac7482cf 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,10 @@ "dev": "echo 'Try npm run dev-firefox or npm run dev-chrome instead' && exit 0", "eslint": "eslint '*.js' shared/js shared/data unit-test integration-test scripts", "eslint-fix": "npm run eslint -- --fix", - "lint": "npm run eslint && prettier . --check && npm run tsc", + "prettier": "prettier . --check", + "prettier-fix": "prettier . --write", + "lint": "npm run eslint && npm run prettier && npm run tsc", + "lint-fix": "npm run eslint-fix && npm run prettier-fix", "test": "npm run test.unit && npm run test.node", "test.unit": "make unit-test", "test.node": "make node-test", From 93e8eee8e789f54c20dab04e18a02a55b4e84d29 Mon Sep 17 00:00:00 2001 From: Maxim Tsoy Date: Fri, 6 Dec 2024 14:57:01 +0100 Subject: [PATCH 2/2] Fix typo --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 01e9ef4cf1..a822cbe626 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,9 +108,9 @@ The extension imports several DDG-owned modules (see [package.json](https://gith ### Linting - All linting: `npm run lint` - This includes the ESLint and TypeScript checks as well as Prettier style checks. - - To auto-fix all lint issues: `npm run lint-fix` + - To automatically fix all lint issues: `npm run lint-fix` - ESLint linting: `npm run eslint` - - To automatically fix mistakes found (where possible) use: `npm run lint-fix` + - To automatically fix mistakes found (where possible) use: `npm run eslint-fix` - TypeScript Linting: `npm run tsc` - Prettier linting: `npm run prettier` - To automatically fix style issues use: `npm run prettier-fix`