From 11c2024cbbfdfa776f4900ae3b2fefadb2e99fd1 Mon Sep 17 00:00:00 2001 From: Martin Man Date: Tue, 8 Oct 2024 11:24:10 +0200 Subject: [PATCH 1/5] fix: avoid using bigint literal syntax --- src/errors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/errors.js b/src/errors.js index c999d49d2..a55c1e45a 100644 --- a/src/errors.js +++ b/src/errors.js @@ -335,8 +335,8 @@ E( received = addNumericalSeparator(String(input)) } else if (typeof input === 'bigint') { received = String(input) - - if (input > 2n ** 32n || input < -(2n ** 32n)) { + const limit = BigInt("2") ** BigInt("32") + if (input > limit || input < -limit) { received = addNumericalSeparator(received) } From e4733f89811584a3b3d76d10c40879d43c2dcfa8 Mon Sep 17 00:00:00 2001 From: Martin Man Date: Tue, 8 Oct 2024 12:25:14 +0200 Subject: [PATCH 2/5] simplify --- src/errors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/errors.js b/src/errors.js index a55c1e45a..070989aa5 100644 --- a/src/errors.js +++ b/src/errors.js @@ -335,7 +335,7 @@ E( received = addNumericalSeparator(String(input)) } else if (typeof input === 'bigint') { received = String(input) - const limit = BigInt("2") ** BigInt("32") + const limit = BigInt(2) ** BigInt(32) if (input > limit || input < -limit) { received = addNumericalSeparator(received) } From 80b6aa0c5cda1d65bad05231330e0602f4404283 Mon Sep 17 00:00:00 2001 From: Martin Man Date: Fri, 29 Nov 2024 11:31:18 +0100 Subject: [PATCH 3/5] fix: Add custom eslint plugin with no-big-int rule --- eslint-plugin-local/index.mjs | 9 +++++++++ eslint-plugin-local/no-big-int.mjs | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 eslint-plugin-local/index.mjs create mode 100644 eslint-plugin-local/no-big-int.mjs diff --git a/eslint-plugin-local/index.mjs b/eslint-plugin-local/index.mjs new file mode 100644 index 000000000..ade9e6923 --- /dev/null +++ b/eslint-plugin-local/index.mjs @@ -0,0 +1,9 @@ +'use strict' + +import nbi from './no-big-int.mjs' + +export default { + rules: { + 'no-big-int': nbi, + }, +} \ No newline at end of file diff --git a/eslint-plugin-local/no-big-int.mjs b/eslint-plugin-local/no-big-int.mjs new file mode 100644 index 000000000..242c08ab0 --- /dev/null +++ b/eslint-plugin-local/no-big-int.mjs @@ -0,0 +1,26 @@ +'use strict' + +export default { + meta: { + docs: { + description: 'disallow `bigint` syntax', + category: 'ES2020', + recommended: false, + }, + fixable: null, + messages: { + forbidden: 'ES2020 `bigint` syntax is forbidden.', + }, + schema: [], + type: 'problem', + }, + create(context) { + return { + Literal(node) { + if (node.bigint != null) { + context.report({ messageId: 'forbidden', node }) + } + }, + } + }, +} From 555bece02da6fe910ccac1df9e4234b6ac094f11 Mon Sep 17 00:00:00 2001 From: Martin Man Date: Fri, 29 Nov 2024 11:31:34 +0100 Subject: [PATCH 4/5] fix: Migrate .eslintrc.js to flat format eslint.config.mjs --- .eslintrc.js | 23 ----------------------- eslint.config.mjs | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 eslint.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 76499b9ad..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - parserOptions: { - ecmaVersion: 'latest' - }, - extends: ['standard'], - rules: { - /* - This is inserted to make this compatible with prettier. - Once https://github.com/prettier/prettier/issues/3845 and https://github.com/prettier/prettier/issues/3847 are solved this might be not needed any more. - */ - 'space-before-function-paren': 0, - curly: [2, 'all'] - }, - overrides: [ - { - files: ['**/*.mjs'], - parserOptions: { - ecmaVersion: 'latest', - sourceType: 'module' - } - } - ] -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..cf74cc0a2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,27 @@ +import { FlatCompat } from '@eslint/eslintrc' +const compat = new FlatCompat() + +import eslintPluginLocal from './eslint-plugin-local/index.mjs' + +export default [ + // standard, + ...compat.extends('eslint-config-standard'), + { + files: ['**/**.js', '**/**.mjs'], + languageOptions: { + sourceType: 'module', + ecmaVersion: 'latest', + }, + plugins: { 'local': eslintPluginLocal }, + rules: { + /* + This is inserted to make this compatible with prettier. + Once https://github.com/prettier/prettier/issues/3845 and https://github.com/prettier/prettier/issues/3847 are solved this might be not needed any more. + */ + 'space-before-function-paren': 0, + curly: [2, 'all'], + 'local/no-big-int': 'error', + }, + }, +] + From ff82310e5f9755e68ddc7e6af7f930e41b05c95c Mon Sep 17 00:00:00 2001 From: Martin Man Date: Wed, 18 Dec 2024 13:59:13 +0100 Subject: [PATCH 5/5] fix(gh): exclude node 12.x, 14.x on macos-latest --- .github/workflows/bundlers.yml | 4 ++++ .github/workflows/node.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/bundlers.yml b/.github/workflows/bundlers.yml index d0bf98c48..e76de6d13 100644 --- a/.github/workflows/bundlers.yml +++ b/.github/workflows/bundlers.yml @@ -20,6 +20,10 @@ jobs: node-version: 12.x - os: windows-latest node-version: 14.x + - os: macos-latest + node-version: 12.x + - os: macos-latest + node-version: 14.x steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index f94148058..a5df24971 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -19,6 +19,10 @@ jobs: node-version: 12.x - os: windows-latest node-version: 14.x + - os: macos-latest + node-version: 12.x + - os: macos-latest + node-version: 14.x steps: - name: Checkout uses: actions/checkout@v3