From 07cb94aa124c69395aec8106244249d20c426dfe Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Wed, 10 Sep 2025 15:57:55 +0200 Subject: [PATCH] Upgrade linting tooling to latest version Signed-off-by: Jon Koops --- .eslintrc.json | 27 - .github/actions/npm-publish/action.yml | 6 +- .github/actions/tag-exists/action.yml | 2 +- .github/stale.yml | 2 +- .github/workflows/build.yml | 17 +- .github/workflows/npm-release.yml | 4 +- .github/workflows/release.yml | 2 +- .github/workflows/semgrep.yml | 2 +- .github/workflows/snyk.yml | 2 +- CHANGELOG.md | 7 + README.md | 16 +- eslint.config.ts | 26 + lib/index.ts | 4 +- package-lock.json | 5527 +++++------------------- package.json | 29 +- static/index.html | 2 +- tsconfig.build.json | 5 +- tsconfig.cjs.json | 2 +- tsconfig.json | 9 +- 19 files changed, 1154 insertions(+), 4537 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.ts diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 22820ff..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "ignorePatterns": ["build", "coverage"], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended-type-checked", - "plugin:@typescript-eslint/stylistic-type-checked", - "plugin:import/recommended", - "plugin:import/typescript", - "plugin:prettier/recommended" - ], - "overrides": [ - { - "files": ["lib/**"], - "rules": { - "import/no-default-export": "error" - } - } - ], - "settings": { - "import/resolver": { - "typescript": true - } - }, - "parserOptions": { - "project": true - } -} diff --git a/.github/actions/npm-publish/action.yml b/.github/actions/npm-publish/action.yml index 57679d5..cfa261b 100644 --- a/.github/actions/npm-publish/action.yml +++ b/.github/actions/npm-publish/action.yml @@ -10,7 +10,7 @@ inputs: require-build: default: true release-directory: - default: './' + default: "./" runs: using: composite @@ -23,8 +23,8 @@ runs: uses: actions/setup-node@v4 with: node-version: ${{ inputs.node-version }} - cache: 'npm' - registry-url: 'https://registry.npmjs.org' + cache: "npm" + registry-url: "https://registry.npmjs.org" - name: Install dependencies shell: bash diff --git a/.github/actions/tag-exists/action.yml b/.github/actions/tag-exists/action.yml index b5fbdb7..ca8f57c 100644 --- a/.github/actions/tag-exists/action.yml +++ b/.github/actions/tag-exists/action.yml @@ -14,7 +14,7 @@ inputs: outputs: exists: - description: 'Whether the tag exists or not' + description: "Whether the tag exists or not" value: ${{ steps.tag-exists.outputs.EXISTS }} runs: diff --git a/.github/stale.yml b/.github/stale.yml index b2e13fc..3cc35f1 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -17,4 +17,4 @@ staleLabel: closed:stale # Comment to post when marking as stale. Set to `false` to disable markComment: > - This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️ \ No newline at end of file + This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 604028f..b75ea9d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,9 +3,9 @@ name: Build and Test on: workflow_dispatch: push: - branches: [ main, beta ] + branches: [main, beta] pull_request: - branches: [ main, beta ] + branches: [main, beta] permissions: contents: read @@ -15,11 +15,10 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - build: strategy: matrix: - node: [ 18, 20 ] + node: [18, 20] name: Build Package (Node ${{ matrix.node }}) runs-on: ubuntu-latest @@ -35,15 +34,15 @@ jobs: - name: Install dependencies run: npm ci - + - name: Build package run: npm run build - + - name: Lint - run: npm run lint && npm run lint:package - + run: npm run lint && npm run lint:package && npm run format:check + - name: Run tests against browser run: npm run test:browser - + - name: Run tests against Node run: npm run test:node diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml index 1595357..2ea5822 100644 --- a/.github/workflows/npm-release.yml +++ b/.github/workflows/npm-release.yml @@ -10,7 +10,7 @@ on: default: true type: string release-directory: - default: './' + default: "./" type: string secrets: github-token: @@ -77,4 +77,4 @@ jobs: body: ${{ steps.get_release_notes.outputs.release-notes }} tag: ${{ steps.get_version.outputs.version }} commit: ${{ github.sha }} - prerelease: ${{ steps.get_prerelease.outputs.prerelease }} \ No newline at end of file + prerelease: ${{ steps.get_prerelease.outputs.prerelease }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 592a3e3..fd2fc4b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,4 +22,4 @@ jobs: require-build: true secrets: npm-token: ${{ secrets.NPM_TOKEN }} - github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index e0e8f42..4e997b1 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -7,7 +7,7 @@ on: branches: ["master", "main"] schedule: - - cron: '30 0 1,15 * *' + - cron: "30 0 1,15 * *" jobs: semgrep: diff --git a/.github/workflows/snyk.yml b/.github/workflows/snyk.yml index 29e6b3a..bb23d68 100644 --- a/.github/workflows/snyk.yml +++ b/.github/workflows/snyk.yml @@ -11,7 +11,7 @@ on: branches: - main schedule: - - cron: '30 0 1,15 * *' + - cron: "30 0 1,15 * *" permissions: contents: read diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cc4824..762e83e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,9 +31,11 @@ The `jwtDecode` function is now no longer the default export, and is instead pro [Full Changelog](https://github.com/auth0/jwt-decode/compare/v4.0.0-beta.3..v4.0.0-beta.4) **Breaking changes** + - Raise minimum Node.js version to 18 [\#209](https://github.com/auth0/jwt-decode/pull/209) ([jonkoops](https://github.com/jonkoops)) **Fixed** + - fix default condition should be the last one [\#199](https://github.com/auth0/jwt-decode/pull/199) ([frederikprijck](https://github.com/frederikprijck)) ## Version [4.0.0-beta.3](https://github.com/auth0/jwt-decode/releases/tag/v4.0.0-beta.3) @@ -41,9 +43,11 @@ The `jwtDecode` function is now no longer the default export, and is instead pro [Full Changelog](https://github.com/auth0/jwt-decode/compare/v4.0.0-beta.2..v4.0.0-beta.3) **Breaking changes** + - Drop UMD bundle [\#193](https://github.com/auth0/jwt-decode/pull/193) ([frederikprijck](https://github.com/frederikprijck)) **Changed** + - Use modern JavaScript syntax [\#187](https://github.com/auth0/jwt-decode/pull/187) ([jonkoops](https://github.com/jonkoops)) - Use ESNext as default module system [\#188](https://github.com/auth0/jwt-decode/pull/188) ([jonkoops](https://github.com/jonkoops)) - Avoid using any bundlers but use tsc instead [\#192](https://github.com/auth0/jwt-decode/pull/192) ([frederikprijck](https://github.com/frederikprijck)) @@ -53,10 +57,12 @@ The `jwtDecode` function is now no longer the default export, and is instead pro [Full Changelog](https://github.com/auth0/jwt-decode/compare/v4.0.0-beta.1..v4.0.0-beta.2) **Changed** + - Avoid using default exports [\#175](https://github.com/auth0/jwt-decode/pull/175) ([frederikprijck](https://github.com/frederikprijck)) - Make options optional no default function parameter initializer [\#179](https://github.com/auth0/jwt-decode/pull/179) ([cristobal](https://github.com/cristobal)) **Fixed** + - Ensure types are bundled and correctly linked [\#174](https://github.com/auth0/jwt-decode/pull/174) ([jonkoops](https://github.com/jonkoops)) ## Version [4.0.0-beta.1](https://github.com/auth0/jwt-decode/releases/tag/v4.0.0-beta.1) @@ -64,6 +70,7 @@ The `jwtDecode` function is now no longer the default export, and is instead pro [Full Changelog](https://github.com/auth0/jwt-decode/compare/v4.0.0-beta.0..v4.0.0-beta.1) **Fixed** + - Ensure build is run on prepack [\#167](https://github.com/auth0/jwt-decode/pull/167) ([frederikprijck](https://github.com/frederikprijck)) ## Version [4.0.0-beta.0](https://github.com/auth0/jwt-decode/releases/tag/v4.0.0-beta.0) diff --git a/README.md b/README.md index f7f6e76..95a3de6 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ const decoded = jwtDecode(token); console.log(decoded); /* prints: - * { + * { * foo: "bar", * exp: 1393286893, - * iat: 1393268893 + * iat: 1393268893 * } */ @@ -44,9 +44,9 @@ const decodedHeader = jwtDecode(token, { header: true }); console.log(decodedHeader); /* prints: - * { + * { * typ: "JWT", - * alg: "HS256" + * alg: "HS256" * } */ ``` @@ -73,22 +73,24 @@ global.atob = decode; ## Errors This library works with valid JSON web tokens. The basic format of these token is + ``` [part1].[part2].[part3] ``` + All parts are supposed to be valid base64 (url) encoded json. Depending on the `{ header: