From d828aa848399abdc0de07f42e9dc54e899755d27 Mon Sep 17 00:00:00 2001 From: Sam Tyler Date: Tue, 19 Nov 2024 13:00:00 +1030 Subject: [PATCH 1/3] MI-39 Don't lint built files --- eslint.config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eslint.config.js b/eslint.config.js index 9837aca..85611ce 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -5,4 +5,7 @@ export default [ { settings: { react: { version: '18' } }, }, + { + ignores: ['dist/'], + }, ]; From 7aec3b93d69adf7313575ab13ca87e6daa630c22 Mon Sep 17 00:00:00 2001 From: Sam Tyler Date: Tue, 19 Nov 2024 13:00:41 +1030 Subject: [PATCH 2/3] MI-39 Restore prettier plugin The prettier config doesn't actually do anything. It just removes some rules from the default config that aren't compatible with prettier. To get Prettier to actually work through ESLint, we need the plugin. --- package.json | 2 +- pnpm-lock.yaml | 68 ++++++++++++++++++++++++++++++++++++++++++++------ src/index.js | 4 +-- 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 26b4d1c..d1f9c15 100644 --- a/package.json +++ b/package.json @@ -27,13 +27,13 @@ "@eslint/js": "^9.14.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jsx-a11y": "^6.10.2", + "eslint-plugin-prettier": "^5.2.1", "eslint-plugin-react": "^7.37.2", "eslint-plugin-react-hooks": "^5.0.0", "prettier-plugin-tailwindcss": "^0.6.8", "typescript-eslint": "^8.13.0" }, "devDependencies": { - "@types/eslint-config-prettier": "^6.11.3", "@types/eslint-plugin-jsx-a11y": "^6.9.0", "@types/eslint__js": "^8.42.3", "eslint": "^9.14.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9a0fe7a..f5b3743 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: eslint-plugin-jsx-a11y: specifier: ^6.10.2 version: 6.10.2(eslint@9.14.0) + eslint-plugin-prettier: + specifier: ^5.2.1 + version: 5.2.1(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@9.14.0))(eslint@9.14.0)(prettier@3.3.3) eslint-plugin-react: specifier: ^7.37.2 version: 7.37.2(eslint@9.14.0) @@ -33,9 +36,6 @@ importers: specifier: ^8.13.0 version: 8.13.0(eslint@9.14.0)(typescript@5.6.3) devDependencies: - '@types/eslint-config-prettier': - specifier: ^6.11.3 - version: 6.11.3 '@types/eslint-plugin-jsx-a11y': specifier: ^6.9.0 version: 6.9.0 @@ -132,6 +132,10 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@pkgr/core@0.1.1': + resolution: {integrity: sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==} + engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + '@rollup/rollup-android-arm-eabi@4.24.4': resolution: {integrity: sha512-jfUJrFct/hTA0XDM5p/htWKoNNTbDLY0KRwEt6pyOA6k2fmk0WVwl65PdUdJZgzGEHWx+49LilkcSaumQRyNQw==} cpu: [arm] @@ -222,9 +226,6 @@ packages: cpu: [x64] os: [win32] - '@types/eslint-config-prettier@6.11.3': - resolution: {integrity: sha512-3wXCiM8croUnhg9LdtZUJQwNcQYGWxxdOWDjPe1ykCqJFPVpzAKfs/2dgSoCtAvdPeaponcWPI7mPcGGp9dkKQ==} - '@types/eslint-plugin-jsx-a11y@6.9.0': resolution: {integrity: sha512-5nw0sPyYGCsFibwjOXftxends8Nrh/JLgDtBWj6aJVcN14kHwy1yIy0o1MGLKfCcR27pvUFGgYG+hX2HSX16uA==} @@ -492,6 +493,20 @@ packages: peerDependencies: eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9 + eslint-plugin-prettier@5.2.1: + resolution: {integrity: sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + '@types/eslint': '>=8.0.0' + eslint: '>=8.0.0' + eslint-config-prettier: '*' + prettier: '>=3.0.0' + peerDependenciesMeta: + '@types/eslint': + optional: true + eslint-config-prettier: + optional: true + eslint-plugin-react-hooks@5.0.0: resolution: {integrity: sha512-hIOwI+5hYGpJEc4uPRmz2ulCjAGD/N13Lukkh8cLV0i2IRk/bdZDYjgLVHj+U9Z704kLIdIO6iueGvxNur0sgw==} engines: {node: '>=10'} @@ -549,6 +564,9 @@ packages: fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + fast-diff@1.3.0: + resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==} + fast-glob@3.3.2: resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} engines: {node: '>=8.6.0'} @@ -911,6 +929,10 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + prettier-linter-helpers@1.0.0: + resolution: {integrity: sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==} + engines: {node: '>=6.0.0'} + prettier-plugin-tailwindcss@0.6.8: resolution: {integrity: sha512-dGu3kdm7SXPkiW4nzeWKCl3uoImdd5CTZEJGxyypEPL37Wj0HT2pLqjrvSei1nTeuQfO4PUfjeW5cTUNRLZ4sA==} engines: {node: '>=14.21.3'} @@ -1083,6 +1105,10 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} + synckit@0.9.2: + resolution: {integrity: sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==} + engines: {node: ^14.18.0 || >=16.0.0} + text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} @@ -1096,6 +1122,9 @@ packages: peerDependencies: typescript: '>=4.2.0' + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -1234,6 +1263,8 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 + '@pkgr/core@0.1.1': {} + '@rollup/rollup-android-arm-eabi@4.24.4': optional: true @@ -1288,8 +1319,6 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.24.4': optional: true - '@types/eslint-config-prettier@6.11.3': {} - '@types/eslint-plugin-jsx-a11y@6.9.0': dependencies: '@types/eslint': 9.6.1 @@ -1680,6 +1709,16 @@ snapshots: safe-regex-test: 1.0.3 string.prototype.includes: 2.0.1 + eslint-plugin-prettier@5.2.1(@types/eslint@9.6.1)(eslint-config-prettier@9.1.0(eslint@9.14.0))(eslint@9.14.0)(prettier@3.3.3): + dependencies: + eslint: 9.14.0 + prettier: 3.3.3 + prettier-linter-helpers: 1.0.0 + synckit: 0.9.2 + optionalDependencies: + '@types/eslint': 9.6.1 + eslint-config-prettier: 9.1.0(eslint@9.14.0) + eslint-plugin-react-hooks@5.0.0(eslint@9.14.0): dependencies: eslint: 9.14.0 @@ -1775,6 +1814,8 @@ snapshots: fast-deep-equal@3.1.3: {} + fast-diff@1.3.0: {} + fast-glob@3.3.2: dependencies: '@nodelib/fs.stat': 2.0.5 @@ -2129,6 +2170,10 @@ snapshots: prelude-ls@1.2.1: {} + prettier-linter-helpers@1.0.0: + dependencies: + fast-diff: 1.3.0 + prettier-plugin-tailwindcss@0.6.8(prettier@3.3.3): dependencies: prettier: 3.3.3 @@ -2301,6 +2346,11 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} + synckit@0.9.2: + dependencies: + '@pkgr/core': 0.1.1 + tslib: 2.8.1 + text-table@0.2.0: {} to-regex-range@5.0.1: @@ -2311,6 +2361,8 @@ snapshots: dependencies: typescript: 5.6.3 + tslib@2.8.1: {} + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 diff --git a/src/index.js b/src/index.js index 7cd1492..0382ac9 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ import eslint from '@eslint/js'; -import eslintConfigPrettier from 'eslint-config-prettier'; +import eslintPluginPrettier from 'eslint-plugin-prettier/recommended'; import { fixupPluginRules } from '@eslint/compat'; import hooksPlugin from 'eslint-plugin-react-hooks'; import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'; @@ -9,7 +9,7 @@ import tsEslint from 'typescript-eslint'; const core = [ eslint.configs.recommended, ...tsEslint.configs.recommended, - eslintConfigPrettier, + eslintPluginPrettier, { rules: { 'no-restricted-syntax': [ From d93d6ceb47cb7dfc36a4e8c57d9f216f89cd08b0 Mon Sep 17 00:00:00 2001 From: Sam Tyler Date: Tue, 19 Nov 2024 13:03:52 +1030 Subject: [PATCH 3/3] MI-39 Remove explicit format steps The format checks are handled through ESLint. Now that ESLint is fixed up to be functioning properly, there is no more need for separate format scripts. --- .github/workflows/pull-request.yml | 25 ------------------------- package.json | 5 +---- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 34ce173..2456c2d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -30,28 +30,3 @@ jobs: - name: Run Tests run: pnpm test - - code-quality: - name: 🕵️‍♀️ Code Quality - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.ref }} - - - name: Fetch target - run: git fetch origin ${{ github.event.pull_request.base.ref }} - - - uses: pnpm/action-setup@v4.0.0 - - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'pnpm' - - - name: Install - run: pnpm install - - - name: Code Quality Check - run: pnpm format:check diff --git a/package.json b/package.json index d1f9c15..3fb67cf 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,7 @@ ], "scripts": { "test": "tsc && eslint .", - "build": "rollup -c", - "format": "prettier --ignore-path .prettierignore --check \"**/*.+(js|ts|json)\"", - "format:check": "pnpm run format", - "format:fix": "prettier --ignore-path .prettierignore --write \"**/*.+(js|ts|json)\"" + "build": "rollup -c" }, "dependencies": { "@eslint/compat": "^1.2.2",