From: Jérôme Benoit Date: Thu, 7 Mar 2024 19:31:57 +0000 (+0100) Subject: refactor: automatically sort imports X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0c01f51c5673eefd485edfab3f8cea93a56f400e;p=benchmarks-js.git refactor: automatically sort imports Signed-off-by: Jérôme Benoit --- diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 1a4b9ab..d1ccd64 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -8,10 +8,10 @@ module.exports = defineConfig({ node: true }, parserOptions: { - ecmaVersion: 2022, - sourceType: 'module' + sourceType: 'module', + ecmaVersion: 2022 }, - plugins: ['promise', 'jsdoc'], + plugins: ['simple-import-sort', 'promise', 'jsdoc'], extends: [ 'standard', 'eslint:recommended', @@ -19,5 +19,9 @@ module.exports = defineConfig({ 'plugin:jsdoc/recommended', 'plugin:import/recommended', 'plugin:promise/recommended' - ] + ], + rules: { + 'simple-import-sort/imports': 'error', + 'simple-import-sort/exports': 'error' + } }) diff --git a/benchmark-utils.mjs b/benchmark-utils.mjs index 1d486bf..d0d5a62 100644 --- a/benchmark-utils.mjs +++ b/benchmark-utils.mjs @@ -1,4 +1,4 @@ -import { randomBytes, getRandomValues, randomInt } from 'node:crypto' +import { getRandomValues, randomBytes, randomInt } from 'node:crypto' /** * Generate a cryptographically secure random number in the [0,1[ range diff --git a/busy-wait.mjs b/busy-wait.mjs index eeef8fe..e5aaaea 100644 --- a/busy-wait.mjs +++ b/busy-wait.mjs @@ -1,4 +1,5 @@ import Benchmark from 'benny' + import { sleep } from './benchmark-utils.mjs' const timeout = 2000 diff --git a/deep-clone-object.mjs b/deep-clone-object.mjs index bd8b3e6..989a04f 100644 --- a/deep-clone-object.mjs +++ b/deep-clone-object.mjs @@ -1,8 +1,9 @@ /* eslint-disable no-unused-vars */ import Benchmark from 'benny' -import _ from 'lodash' -import clone from 'just-clone' import deepClone from 'deep-clone' +import clone from 'just-clone' +import _ from 'lodash' + import { generateRandomObject } from './benchmark-utils.mjs' const object = generateRandomObject() diff --git a/deep-merge-object.mjs b/deep-merge-object.mjs index fe1440f..1fbf315 100644 --- a/deep-merge-object.mjs +++ b/deep-merge-object.mjs @@ -1,8 +1,9 @@ /* eslint-disable no-unused-vars */ import Benchmark from 'benny' -import _ from 'lodash' -import merge from 'just-merge' import deepMerge from 'deepmerge' +import merge from 'just-merge' +import _ from 'lodash' + import { generateRandomObject } from './benchmark-utils.mjs' const object = generateRandomObject() diff --git a/empty-array.mjs b/empty-array.mjs index 3c46e35..f9bd214 100644 --- a/empty-array.mjs +++ b/empty-array.mjs @@ -1,4 +1,5 @@ import Benchmark from 'benny' + import { generateRandomNumberArray } from './benchmark-utils.mjs' const size = 10000 diff --git a/is-empty-object.mjs b/is-empty-object.mjs index e9b42f7..f110816 100644 --- a/is-empty-object.mjs +++ b/is-empty-object.mjs @@ -1,4 +1,5 @@ import Benchmark from 'benny' + import { generateRandomObject } from './benchmark-utils.mjs' const object = generateRandomObject() diff --git a/max.mjs b/max.mjs index 0b1ec9f..2708eb0 100644 --- a/max.mjs +++ b/max.mjs @@ -1,4 +1,5 @@ import Benchmark from 'benny' + import { generateRandomNumberArray } from './benchmark-utils.mjs' const size = 10000 diff --git a/min.mjs b/min.mjs index 834076c..c7efed1 100644 --- a/min.mjs +++ b/min.mjs @@ -1,4 +1,5 @@ import Benchmark from 'benny' + import { generateRandomNumberArray } from './benchmark-utils.mjs' const size = 10000 diff --git a/package.json b/package.json index 607bfb0..ffdc143 100644 --- a/package.json +++ b/package.json @@ -77,9 +77,10 @@ "eslint-config-standard": "^17.1.0", "eslint-define-config": "^2.1.0", "eslint-plugin-import": "^2.29.1", - "eslint-plugin-jsdoc": "^48.2.0", + "eslint-plugin-jsdoc": "^48.2.1", "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-simple-import-sort": "^12.0.0", "husky": "^9.0.11", "lint-staged": "^15.2.2", "prettier": "^3.2.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bddae38..94e1af1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,14 +56,17 @@ devDependencies: specifier: ^2.29.1 version: 2.29.1(eslint@8.57.0) eslint-plugin-jsdoc: - specifier: ^48.2.0 - version: 48.2.0(eslint@8.57.0) + specifier: ^48.2.1 + version: 48.2.1(eslint@8.57.0) eslint-plugin-n: specifier: ^16.6.2 version: 16.6.2(eslint@8.57.0) eslint-plugin-promise: specifier: ^6.1.1 version: 6.1.1(eslint@8.57.0) + eslint-plugin-simple-import-sort: + specifier: ^12.0.0 + version: 12.0.0(eslint@8.57.0) husky: specifier: ^9.0.11 version: 9.0.11 @@ -1312,8 +1315,8 @@ packages: - supports-color dev: true - /eslint-plugin-jsdoc@48.2.0(eslint@8.57.0): - resolution: {integrity: sha512-O2B1XLBJnUCRkggFzUQ+PBYJDit8iAgXdlu8ucolqGrbmOWPvttZQZX8d1sC0MbqDMSLs8SHSQxaNPRY1RQREg==} + /eslint-plugin-jsdoc@48.2.1(eslint@8.57.0): + resolution: {integrity: sha512-iUvbcyDZSO/9xSuRv2HQBw++8VkV/pt3UWtX9cpPH0l7GKPq78QC/6+PmyQHHvNZaTjAce6QVciEbnc6J/zH5g==} engines: {node: '>=18'} peerDependencies: eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 @@ -1359,7 +1362,7 @@ packages: builtins: 5.0.1 eslint: 8.57.0 eslint-plugin-es-x: 7.5.0(eslint@8.57.0) - get-tsconfig: 4.7.2 + get-tsconfig: 4.7.3 globals: 13.24.0 ignore: 5.3.1 is-builtin-module: 3.2.1 @@ -1405,6 +1408,14 @@ packages: string.prototype.matchall: 4.0.10 dev: true + /eslint-plugin-simple-import-sort@12.0.0(eslint@8.57.0): + resolution: {integrity: sha512-8o0dVEdAkYap0Cn5kNeklaKcT1nUsa3LITWEuFk3nJifOoD+5JQGoyDUW2W/iPWwBsNBJpyJS9y4je/BgxLcyQ==} + peerDependencies: + eslint: '>=5.0.0' + dependencies: + eslint: 8.57.0 + dev: true + /eslint-scope@7.2.2: resolution: {integrity: sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1689,8 +1700,8 @@ packages: get-intrinsic: 1.2.4 dev: true - /get-tsconfig@4.7.2: - resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} + /get-tsconfig@4.7.3: + resolution: {integrity: sha512-ZvkrzoUA0PQZM6fy6+/Hce561s+faD1rsNwhnO5FelNjyy7EMGJ3Rz1AQ8GYDWjhRs/7dBLOEJvhK8MiEJOAFg==} dependencies: resolve-pkg-maps: 1.0.0 dev: true diff --git a/quick-select.mjs b/quick-select.mjs index d427026..a829a9e 100644 --- a/quick-select.mjs +++ b/quick-select.mjs @@ -1,4 +1,5 @@ import { randomInt } from 'node:crypto' + import Benchmark from 'benny' /** diff --git a/random.mjs b/random.mjs index f01ab2b..bdb5f58 100644 --- a/random.mjs +++ b/random.mjs @@ -1,5 +1,7 @@ import { randomInt } from 'node:crypto' + import Benchmark from 'benny' + import { secureRandom, secureRandomWithRandomValues diff --git a/shallow-clone-object.mjs b/shallow-clone-object.mjs index 51ee172..466135e 100644 --- a/shallow-clone-object.mjs +++ b/shallow-clone-object.mjs @@ -1,6 +1,7 @@ /* eslint-disable no-unused-vars */ import Benchmark from 'benny' import _ from 'lodash' + import { generateRandomObject } from './benchmark-utils.mjs' const object = generateRandomObject() diff --git a/uuid-generator.mjs b/uuid-generator.mjs index 325abcb..0b4c9fb 100644 --- a/uuid-generator.mjs +++ b/uuid-generator.mjs @@ -1,4 +1,5 @@ import { randomUUID } from 'node:crypto' + import Benchmark from 'benny' import { v4 as uuid } from 'uuid'