From e6ef0d6d635b0cfcef248b69c281163cbbe1b29e Mon Sep 17 00:00:00 2001 From: mizdra Date: Mon, 6 Nov 2023 00:45:13 +0900 Subject: [PATCH 1/6] do not use solution-style tsconfig.json --- .eslintignore | 2 -- .eslintrc.cjs | 2 +- .prettierignore | 2 -- e2e-test/tsconfig.json | 3 ++- package.json | 10 +++++----- pnpm-lock.yaml | 14 +++++++++++++ tsconfig.base.json | 45 ------------------------------------------ tsconfig.build.json | 13 ++++++++++++ tsconfig.json | 31 +++++++++++++++++++++-------- tsconfig.src.json | 11 ----------- tsconfig.test.json | 11 ----------- 11 files changed, 58 insertions(+), 86 deletions(-) delete mode 100644 tsconfig.base.json create mode 100644 tsconfig.build.json delete mode 100644 tsconfig.src.json delete mode 100644 tsconfig.test.json diff --git a/.eslintignore b/.eslintignore index cb23ef7e..262a9dd8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,4 @@ /coverage /dist -/tsconfig.src.tsbuildinfo -/tsconfig.test.tsbuildinfo /bin /static diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 64faf629..32fb8c82 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -46,7 +46,7 @@ module.exports = { files: ['*.ts', '*.tsx', '*.cts', '*.mts'], extends: ['@mizdra/mizdra/+typescript', '@mizdra/mizdra/+prettier'], parserOptions: { - project: ['./tsconfig.src.json', './tsconfig.test.json', './e2e-test/import-as-esm-from-esm/tsconfig.json'], + project: ['./tsconfig.json', './e2e-test/import-as-esm-from-esm/tsconfig.json'], }, }, // for test diff --git a/.prettierignore b/.prettierignore index f467c172..c03bfc33 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,7 +1,5 @@ /coverage /dist /fixtures -/tsconfig.src.tsbuildinfo -/tsconfig.test.tsbuildinfo pnpm-lock.yaml /.pnpm-store diff --git a/e2e-test/tsconfig.json b/e2e-test/tsconfig.json index 7cb862f6..fe7e6836 100644 --- a/e2e-test/tsconfig.json +++ b/e2e-test/tsconfig.json @@ -1,6 +1,7 @@ { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "include": ["**/*"], + "exclude": ["node_modules"], "compilerOptions": { "outDir": "./dist/", // Compatible for Node.js v12 (ref: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping) diff --git a/package.json b/package.json index b81ad6b5..a1a5029b 100644 --- a/package.json +++ b/package.json @@ -16,12 +16,10 @@ } }, "scripts": { - "build": "tsc -p tsconfig.src.json", - "dev": "tsc-watch -p tsconfig.src.json --onSuccess 'bin/eslint-interactive.js fixtures --rulesdir fixtures/rules --ext .js,.jsx,.mjs'", + "build": "tsc -p tsconfig.build.json", + "dev": "tsc-watch -p tsconfig.build.json --onSuccess 'bin/eslint-interactive.js fixtures --rulesdir fixtures/rules --ext .js,.jsx,.mjs'", "lint": "run-s -c lint:*", - "lint:tsc": "run-s -c lint:tsc:*", - "lint:tsc:src": "tsc -p tsconfig.src.json --noEmit", - "lint:tsc:test": "tsc -p tsconfig.test.json --noEmit", + "lint:tsc": "tsc -p tsconfig.json --noEmit", "lint:eslint": "eslint --ignore-pattern '/fixtures/' --ignore-pattern '/e2e-test/' .", "lint:prettier": "prettier --check .", "test": "cross-env FORCE_HYPERLINK=1 NODE_OPTIONS=\"--experimental-vm-modules --experimental-import-meta-resolve $NODE_OPTIONS\" jest --colors", @@ -36,6 +34,8 @@ "@jest/types": "^29.6.3", "@mizdra/eslint-config-mizdra": "^2.0.0", "@mizdra/prettier-config-mizdra": "^1.0.0", + "@tsconfig/node18": "^18.2.2", + "@tsconfig/strictest": "^2.0.2", "@types/eslint": "^8.44.6", "@types/estraverse": "^5.1.5", "@types/estree": "^1.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 29b5ab5b..62b9daa4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -61,6 +61,12 @@ devDependencies: '@mizdra/prettier-config-mizdra': specifier: ^1.0.0 version: 1.0.0(prettier@3.0.3) + '@tsconfig/node18': + specifier: ^18.2.2 + version: 18.2.2 + '@tsconfig/strictest': + specifier: ^2.0.2 + version: 2.0.2 '@types/eslint': specifier: ^8.44.6 version: 8.44.6 @@ -988,6 +994,14 @@ packages: '@sinonjs/commons': 3.0.0 dev: true + /@tsconfig/node18@18.2.2: + resolution: {integrity: sha512-d6McJeGsuoRlwWZmVIeE8CUA27lu6jLjvv1JzqmpsytOYYbVi1tHZEnwCNVOXnj4pyLvneZlFlpXUK+X9wBWyw==} + dev: true + + /@tsconfig/strictest@2.0.2: + resolution: {integrity: sha512-jt4jIsWKvUvuY6adJnQJlb/UR7DdjC8CjHI/OaSQruj2yX9/K6+KOvDt/vD6udqos/FUk5Op66CvYT7TBLYO5Q==} + dev: true + /@types/babel__core@7.20.3: resolution: {integrity: sha512-54fjTSeSHwfan8AyHWrKbfBWiEUrNTZsUwPTDSNaaP1QDQIZbeNUg3a59E9D+375MzUw/x1vx2/0F5LBz+AeYA==} dependencies: diff --git a/tsconfig.base.json b/tsconfig.base.json deleted file mode 100644 index a1793d5f..00000000 --- a/tsconfig.base.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - // "include": ["src/**/*"], - "exclude": ["node_modules", "benchmark/fixtures", "fixtures-tmp"], - "compilerOptions": { - /* Basic Options */ - // "outDir": "./dist", // 継承先で上書きする - // "target": "esnext", // 継承先で上書きする - // "lib": ["esnext", "dom"], // 継承先で上書きする - "isolatedModules": true, // for isolated file emit (ref: https://github.com/microsoft/TypeScript/wiki/Performance#isolated-file-emit , https://www.typescriptlang.org/v2/ja/tsconfig#isolatedModules) - // "importsNotUsedAsValues": "error", // for isolated file emit (https://www.typescriptlang.org/v2/ja/tsconfig#isolatedModules , https://qiita.com/vvakame/items/72da760526ec7cc25c2d#%E5%9E%8B%E3%81%AE%E3%81%BF%E3%81%AEimport-export%E3%81%AE%E3%82%B5%E3%83%9D%E3%83%BC%E3%83%88) - "declaration": true, // Project Reference で依存された先から型が読み込めるように - "declarationMap": true, // Project Reference で依存された先から *.ts が追跡できるように - "incremental": true, // ビルド結果をキャッシュするように - - /* Module Options */ - "module": "Node16", - "esModuleInterop": false, // `"module": "node12"` との相性が悪いので off にする - "resolveJsonModule": true, // import した json の型を推論するように - "forceConsistentCasingInFileNames": true, // 大文字小文字を区別しない環境 (win) でも unix と同じように区別する - // 🤯🤯🤯 THIS IS SUPER HACK!!! 🤯🤯🤯 - // - comlink provides an ESM module (ex. `comlink/dist/esm/node-adapter.mjs`) - // - Of course, comlink also provide type definitions (ex. `comlink/dist/esm/node-adapter.d.ts`) - // - However, the corresponding type definition for `xxx.mjs` is `xxx.d.mts` in `"module": "node12"` mode - // - Therefore, importing the ESM module causes compilation errors - // - So, use `paths` option to force `xxx.mjs` to be mapped to `xxx.d.ts`. - "baseUrl": ".", - "paths": { - "comlink/dist/esm/node-adapter.mjs": ["./node_modules/comlink/dist/esm/node-adapter.js"] - }, - - /* Additional Features */ - // "jsx": "react", - - /* Strict Type-Checking Options */ - "strict": true, - "skipLibCheck": true, - - /* Lint Options */ - "noUnusedLocals": true, - "noUnusedParameters": true, - - /* Debug Options */ - "sourceMap": true // for ts-loader (ref: https://github.com/TypeStrong/ts-loader#devtool--sourcemaps) - } -} diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..e20943b7 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "include": ["src/**/*"], + "exclude": ["src/**/*.test.ts", "src/test-util/**", "!src/**/__snapshots__"], + "compilerOptions": { + "noEmit": false, + "outDir": "./dist", + "rootDir": "src", // To avoid inadvertently changing the directory structure under dist/. + "sourceMap": true, + "declaration": true, + "declarationMap": true + } +} diff --git a/tsconfig.json b/tsconfig.json index 99174b81..daa985cf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,25 @@ -// 🙏 "Solution Style" tsconfig.json 🙏 -// ref: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#support-for-solution-style-tsconfigjson-files { - "files": [], - "references": [ - { "path": "./tsconfig.src.json" }, - { "path": "./tsconfig.test.json" }, - { "path": "./e2e-test/tsconfig.json" } - ] + "extends": ["@tsconfig/strictest/tsconfig.json", "@tsconfig/node18/tsconfig.json"], + "exclude": ["node_modules", "benchmark", "static", "e2e-test", "fixtures", "fixtures-tmp", "dist", "bin"], + "compilerOptions": { + "module": "Node16", + "moduleResolution": "node16", + "noEmit": true, + "incremental": true, + "tsBuildInfoFile": "node_modules/.cache/typescript/.tsbuildinfo", + /* Lint Options */ + "noUnusedLocals": false, // Delegate to @typescript-eslint/no-unused-vars in eslint + "noUnusedParameters": false, // Delegate to @typescript-eslint/no-unused-vars in eslint + + // 🤯🤯🤯 THIS IS SUPER HACK!!! 🤯🤯🤯 + // - comlink provides an ESM module (ex. `comlink/dist/esm/node-adapter.mjs`) + // - Of course, comlink also provide type definitions (ex. `comlink/dist/esm/node-adapter.d.ts`) + // - However, the corresponding type definition for `xxx.mjs` is `xxx.d.mts` in `"module": "node12"` mode + // - Therefore, importing the ESM module causes compilation errors + // - So, use `paths` option to force `xxx.mjs` to be mapped to `xxx.d.ts`. + "baseUrl": ".", + "paths": { + "comlink/dist/esm/node-adapter.mjs": ["./node_modules/comlink/dist/esm/node-adapter.js"] + } + } } diff --git a/tsconfig.src.json b/tsconfig.src.json deleted file mode 100644 index 94a3870e..00000000 --- a/tsconfig.src.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "include": ["src/**/*"], - "exclude": ["src/test-util", "src/**/*.test.ts"], - "compilerOptions": { - "outDir": "./dist/", - // Compatible for Node.js v12 (ref: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping) - "target": "ES2019", - "lib": ["ES2019"] - } -} diff --git a/tsconfig.test.json b/tsconfig.test.json deleted file mode 100644 index 82b2fd65..00000000 --- a/tsconfig.test.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "include": ["src/**/*"], - "compilerOptions": { - // "outDir": "./dist/", - // "rootDir": "./test", - // Compatible for Node.js v12 (ref: https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping) - "target": "ES2019", - "lib": ["ES2019"] - } -} From ff8d1a937418c7a8f22b434aaf3edd8279521826 Mon Sep 17 00:00:00 2001 From: mizdra Date: Mon, 6 Nov 2023 00:50:41 +0900 Subject: [PATCH 2/6] fix type errors --- babel.config.cjs | 1 - src/core.ts | 4 ++-- src/plugin/fix/convert-error-to-warning-per-file.ts | 2 +- src/plugin/fix/disable-per-file.ts | 4 ++-- src/plugin/fix/disable-per-line.ts | 4 ++-- src/util/eslint.ts | 5 +++-- src/util/filter-script.ts | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/babel.config.cjs b/babel.config.cjs index fb315698..8dc946d9 100644 --- a/babel.config.cjs +++ b/babel.config.cjs @@ -1,7 +1,6 @@ // @ts-check 'use strict'; -/** @type {import('@babel/core').TransformOptions} */ const config = { presets: ['@babel/preset-typescript'], }; diff --git a/src/core.ts b/src/core.ts index da39b819..9a5e3d84 100644 --- a/src/core.ts +++ b/src/core.ts @@ -65,8 +65,8 @@ export type Config = Pick< | 'resolvePluginsRelativeTo' > & { patterns: string[]; - formatterName?: string; - quiet?: boolean; + formatterName?: string | undefined; + quiet?: boolean | undefined; }; /** Default config of `Core` */ diff --git a/src/plugin/fix/convert-error-to-warning-per-file.ts b/src/plugin/fix/convert-error-to-warning-per-file.ts index 4217de6e..7e041bed 100644 --- a/src/plugin/fix/convert-error-to-warning-per-file.ts +++ b/src/plugin/fix/convert-error-to-warning-per-file.ts @@ -5,7 +5,7 @@ import { notEmpty } from '../../util/type-check.js'; import { FixContext } from '../index.js'; export type FixToConvertErrorToWarningPerFileArgs = { - description?: string; + description?: string | undefined; }; function generateFix(context: FixContext, description?: string): Rule.Fix | null { diff --git a/src/plugin/fix/disable-per-file.ts b/src/plugin/fix/disable-per-file.ts index c678b512..fe38b046 100644 --- a/src/plugin/fix/disable-per-file.ts +++ b/src/plugin/fix/disable-per-file.ts @@ -15,8 +15,8 @@ import { notEmpty } from '../../util/type-check.js'; import { FixContext } from '../index.js'; export type FixToDisablePerFileArgs = { - description?: string; - descriptionPosition?: DescriptionPosition; + description?: string | undefined; + descriptionPosition?: DescriptionPosition | undefined; }; function findDisableCommentPerFile(sourceCode: SourceCode): DisableComment | undefined { diff --git a/src/plugin/fix/disable-per-line.ts b/src/plugin/fix/disable-per-line.ts index 8fae1881..ea37d3f2 100644 --- a/src/plugin/fix/disable-per-line.ts +++ b/src/plugin/fix/disable-per-line.ts @@ -14,8 +14,8 @@ import { notEmpty } from '../../util/type-check.js'; import { FixContext } from '../index.js'; export type FixToDisablePerLineArgs = { - description?: string; - descriptionPosition?: DescriptionPosition; + description?: string | undefined; + descriptionPosition?: DescriptionPosition | undefined; }; function findDisableCommentPerLine(sourceCode: SourceCode, line: number): DisableComment | undefined { diff --git a/src/util/eslint.ts b/src/util/eslint.ts index 25f44271..3654af36 100644 --- a/src/util/eslint.ts +++ b/src/util/eslint.ts @@ -29,7 +29,7 @@ export type DisableComment = { type: 'Block' | 'Line'; scope: 'next-line' | 'file'; ruleIds: string[]; - description?: string; + description?: string | undefined; range: [number, number]; loc: SourceLocation; }; @@ -57,6 +57,7 @@ export function parseDisableComment(comment: Comment): DisableComment | undefine if (!result.groups) return undefined; const { header, ruleList, description } = result.groups; + if (header === undefined || ruleList === undefined) return undefined; const ruleIds = ruleList .split(',') .map((r) => r.trim()) @@ -215,7 +216,7 @@ export function insertDisableCommentStatementBeforeLine(args: { } export type InlineConfigComment = { - description?: string; + description?: string | undefined; rulesRecord: Partial; range: [number, number]; }; diff --git a/src/util/filter-script.ts b/src/util/filter-script.ts index 17eec32e..eef047b8 100644 --- a/src/util/filter-script.ts +++ b/src/util/filter-script.ts @@ -10,7 +10,7 @@ const exec = promisify(execOriginal); const DEFAULT_EDITOR_COMMAND = 'vi'; function getEditorCommand(): string { - return process.env.EDITOR ?? DEFAULT_EDITOR_COMMAND; + return process.env['EDITOR'] ?? DEFAULT_EDITOR_COMMAND; } export async function editFileWithEditor(filepath: string): Promise { From 0a5c3cc5f20fe27828f2cf75ea4948fd50e10011 Mon Sep 17 00:00:00 2001 From: mizdra Date: Tue, 7 Nov 2023 01:08:58 +0900 Subject: [PATCH 3/6] use eslint-config-mizdra@2.1.0-alpha.0 --- package.json | 2 +- pnpm-lock.yaml | 190 +++++++++++++++---------------------------------- 2 files changed, 57 insertions(+), 135 deletions(-) diff --git a/package.json b/package.json index a1a5029b..1b21575e 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@babel/core": "^7.23.2", "@babel/preset-typescript": "^7.23.2", "@jest/types": "^29.6.3", - "@mizdra/eslint-config-mizdra": "^2.0.0", + "@mizdra/eslint-config-mizdra": "2.1.0-alpha.0", "@mizdra/prettier-config-mizdra": "^1.0.0", "@tsconfig/node18": "^18.2.2", "@tsconfig/strictest": "^2.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 62b9daa4..2978cfcd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,8 +56,8 @@ devDependencies: specifier: ^29.6.3 version: 29.6.3 '@mizdra/eslint-config-mizdra': - specifier: ^2.0.0 - version: 2.0.0(eslint@8.53.0)(prettier@3.0.3)(typescript@5.2.2) + specifier: 2.1.0-alpha.0 + version: 2.1.0-alpha.0(eslint@8.53.0)(prettier@3.0.3)(typescript@5.2.2) '@mizdra/prettier-config-mizdra': specifier: ^1.0.0 version: 1.0.0(prettier@3.0.3) @@ -342,11 +342,6 @@ packages: engines: {node: '>=6.9.0'} dev: true - /@babel/helper-validator-identifier@7.22.5: - resolution: {integrity: sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==} - engines: {node: '>=6.9.0'} - dev: true - /@babel/helper-validator-option@7.22.15: resolution: {integrity: sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==} engines: {node: '>=6.9.0'} @@ -612,11 +607,6 @@ packages: engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} dev: true - /@eslint-community/regexpp@4.5.1: - resolution: {integrity: sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==} - engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} - dev: true - /@eslint/eslintrc@2.1.3: resolution: {integrity: sha512-yZzuIG+jnVu6hNSzFEN07e8BxF3uAzYtQb6uDkaYZLo6oYZDCq454c5kB8zxnzfCYyP4MIuyBn10L0DqwujTmA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -919,8 +909,8 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: true - /@mizdra/eslint-config-mizdra@2.0.0(eslint@8.53.0)(prettier@3.0.3)(typescript@5.2.2): - resolution: {integrity: sha512-eG8m6DpI3V4CttC7/hAPIekU2C+BkVqYM+FsmiAmZU7+4trE7z5uGTScSuMEf95NwDjFf7ARb+N4kxR2s0gqmg==} + /@mizdra/eslint-config-mizdra@2.1.0-alpha.0(eslint@8.53.0)(prettier@3.0.3)(typescript@5.2.2): + resolution: {integrity: sha512-3BQ/CBBfe128WRbsrDDLbNmx3nCuKLt9UL1xqf16v2nZwlYLjOpQ8eS3XPADiUOkPlcjbKu0DCrZ1ubG9TL1MA==} engines: {node: '>=16.0.0'} peerDependencies: eslint: '>=6.8.0' @@ -935,12 +925,12 @@ packages: '@typescript-eslint/eslint-plugin': 5.59.2(@typescript-eslint/parser@5.59.2)(eslint@8.53.0)(typescript@5.2.2) '@typescript-eslint/parser': 5.59.2(eslint@8.53.0)(typescript@5.2.2) eslint: 8.53.0 - eslint-config-prettier: 8.8.0(eslint@8.53.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.59.2)(eslint@8.53.0) + eslint-config-prettier: 9.0.0(eslint@8.53.0) + eslint-plugin-import: /eslint-plugin-i@2.29.0(@typescript-eslint/parser@5.59.2)(eslint@8.53.0) eslint-plugin-n: 15.7.0(eslint@8.53.0) eslint-plugin-react: 7.32.2(eslint@8.53.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.53.0) - eslint-plugin-unicorn: 47.0.0(eslint@8.53.0) + eslint-plugin-unicorn: 49.0.0(eslint@8.53.0) prettier: 3.0.3 typescript: 5.2.2 transitivePeerDependencies: @@ -1088,18 +1078,10 @@ packages: pretty-format: 29.7.0 dev: true - /@types/json-schema@7.0.11: - resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} - dev: true - /@types/json-schema@7.0.14: resolution: {integrity: sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==} dev: true - /@types/json5@0.0.29: - resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} - dev: true - /@types/jsonfile@6.1.3: resolution: {integrity: sha512-/yqTk2SZ1wIezK0hiRZD7RuSf4B3whFxFamB1kGStv+8zlWScTMcHanzfc0XKWs5vA1TkHeckBlOyM8jxU8nHA==} dependencies: @@ -1152,7 +1134,7 @@ packages: typescript: optional: true dependencies: - '@eslint-community/regexpp': 4.5.1 + '@eslint-community/regexpp': 4.10.0 '@typescript-eslint/parser': 5.59.2(eslint@8.53.0)(typescript@5.2.2) '@typescript-eslint/scope-manager': 5.59.2 '@typescript-eslint/type-utils': 5.59.2(eslint@8.53.0)(typescript@5.2.2) @@ -1160,9 +1142,9 @@ packages: debug: 4.3.4 eslint: 8.53.0 grapheme-splitter: 1.0.4 - ignore: 5.2.0 + ignore: 5.2.4 natural-compare-lite: 1.4.0 - semver: 7.5.0 + semver: 7.5.4 tsutils: 3.21.0(typescript@5.2.2) typescript: 5.2.2 transitivePeerDependencies: @@ -1236,7 +1218,7 @@ packages: debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 - semver: 7.5.0 + semver: 7.5.4 tsutils: 3.21.0(typescript@5.2.2) typescript: 5.2.2 transitivePeerDependencies: @@ -1250,14 +1232,14 @@ packages: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.53.0) - '@types/json-schema': 7.0.11 + '@types/json-schema': 7.0.14 '@types/semver': 7.3.13 '@typescript-eslint/scope-manager': 5.59.2 '@typescript-eslint/types': 5.59.2 '@typescript-eslint/typescript-estree': 5.59.2(typescript@5.2.2) eslint: 8.53.0 eslint-scope: 5.1.1 - semver: 7.5.0 + semver: 7.5.4 transitivePeerDependencies: - supports-color - typescript @@ -1268,7 +1250,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: '@typescript-eslint/types': 5.59.2 - eslint-visitor-keys: 3.4.1 + eslint-visitor-keys: 3.4.3 dev: true /@ungap/structured-clone@1.2.0: @@ -1411,16 +1393,6 @@ packages: engines: {node: '>=8'} dev: true - /array.prototype.flat@1.3.1: - resolution: {integrity: sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==} - engines: {node: '>= 0.4'} - dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 - es-abstract: 1.21.2 - es-shim-unscopables: 1.0.0 - dev: true - /array.prototype.flatmap@1.3.1: resolution: {integrity: sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ==} engines: {node: '>= 0.4'} @@ -1603,7 +1575,7 @@ packages: /builtins@5.0.1: resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==} dependencies: - semver: 7.5.0 + semver: 7.5.4 dev: true /call-bind@1.0.2: @@ -1667,11 +1639,6 @@ packages: engines: {node: '>=10'} dev: true - /ci-info@3.8.0: - resolution: {integrity: sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==} - engines: {node: '>=8'} - dev: true - /ci-info@3.9.0: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} @@ -2044,8 +2011,8 @@ packages: engines: {node: '>=10'} dev: true - /eslint-config-prettier@8.8.0(eslint@8.53.0): - resolution: {integrity: sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==} + /eslint-config-prettier@9.0.0(eslint@8.53.0): + resolution: {integrity: sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==} hasBin: true peerDependencies: eslint: '>=7.0.0' @@ -2061,17 +2028,17 @@ packages: chalk: 4.1.2 dev: false - /eslint-import-resolver-node@0.3.7: - resolution: {integrity: sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA==} + /eslint-import-resolver-node@0.3.9: + resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} dependencies: debug: 3.2.7 - is-core-module: 2.12.0 - resolve: 1.22.1 + is-core-module: 2.13.1 + resolve: 1.22.8 transitivePeerDependencies: - supports-color dev: true - /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.59.2)(eslint-import-resolver-node@0.3.7)(eslint@8.53.0): + /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.59.2)(eslint-import-resolver-node@0.3.9)(eslint@8.53.0): resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} engines: {node: '>=4'} peerDependencies: @@ -2095,7 +2062,7 @@ packages: '@typescript-eslint/parser': 5.59.2(eslint@8.53.0)(typescript@5.2.2) debug: 3.2.7 eslint: 8.53.0 - eslint-import-resolver-node: 0.3.7 + eslint-import-resolver-node: 0.3.9 transitivePeerDependencies: - supports-color dev: true @@ -2111,34 +2078,24 @@ packages: regexpp: 3.2.0 dev: true - /eslint-plugin-import@2.27.5(@typescript-eslint/parser@5.59.2)(eslint@8.53.0): - resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} - engines: {node: '>=4'} + /eslint-plugin-i@2.29.0(@typescript-eslint/parser@5.59.2)(eslint@8.53.0): + resolution: {integrity: sha512-slGeTS3GQzx9267wLJnNYNO8X9EHGsc75AKIAFvnvMYEcTJKotPKL1Ru5PIGVHIVet+2DsugePWp8Oxpx8G22w==} + engines: {node: '>=12'} peerDependencies: - '@typescript-eslint/parser': '*' - eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 - peerDependenciesMeta: - '@typescript-eslint/parser': - optional: true + eslint: ^7.2.0 || ^8 dependencies: - '@typescript-eslint/parser': 5.59.2(eslint@8.53.0)(typescript@5.2.2) - array-includes: 3.1.6 - array.prototype.flat: 1.3.1 - array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 eslint: 8.53.0 - eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.59.2)(eslint-import-resolver-node@0.3.7)(eslint@8.53.0) - has: 1.0.3 - is-core-module: 2.12.0 + eslint-import-resolver-node: 0.3.9 + eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.59.2)(eslint-import-resolver-node@0.3.9)(eslint@8.53.0) + get-tsconfig: 4.7.2 is-glob: 4.0.3 minimatch: 3.1.2 - object.values: 1.1.6 - resolve: 1.22.1 - semver: 6.3.1 - tsconfig-paths: 3.14.2 + resolve: 1.22.8 + semver: 7.5.4 transitivePeerDependencies: + - '@typescript-eslint/parser' - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color @@ -2154,11 +2111,11 @@ packages: eslint: 8.53.0 eslint-plugin-es: 4.1.0(eslint@8.53.0) eslint-utils: 3.0.0(eslint@8.53.0) - ignore: 5.2.0 - is-core-module: 2.12.0 + ignore: 5.2.4 + is-core-module: 2.13.1 minimatch: 3.1.2 - resolve: 1.22.1 - semver: 7.5.0 + resolve: 1.22.8 + semver: 7.5.4 dev: true /eslint-plugin-react-hooks@4.6.0(eslint@8.53.0): @@ -2194,28 +2151,26 @@ packages: string.prototype.matchall: 4.0.8 dev: true - /eslint-plugin-unicorn@47.0.0(eslint@8.53.0): - resolution: {integrity: sha512-ivB3bKk7fDIeWOUmmMm9o3Ax9zbMz1Bsza/R2qm46ufw4T6VBFBaJIR1uN3pCKSmSXm8/9Nri8V+iUut1NhQGA==} + /eslint-plugin-unicorn@49.0.0(eslint@8.53.0): + resolution: {integrity: sha512-0fHEa/8Pih5cmzFW5L7xMEfUTvI9WKeQtjmKpTUmY+BiFCDxkxrTdnURJOHKykhtwIeyYsxnecbGvDCml++z4Q==} engines: {node: '>=16'} peerDependencies: - eslint: '>=8.38.0' + eslint: '>=8.52.0' dependencies: - '@babel/helper-validator-identifier': 7.22.5 + '@babel/helper-validator-identifier': 7.22.20 '@eslint-community/eslint-utils': 4.4.0(eslint@8.53.0) - ci-info: 3.8.0 + ci-info: 3.9.0 clean-regexp: 1.0.0 eslint: 8.53.0 esquery: 1.5.0 indent-string: 4.0.0 is-builtin-module: 3.2.1 jsesc: 3.0.2 - lodash: 4.17.21 pluralize: 8.0.0 read-pkg-up: 7.0.1 regexp-tree: 0.1.27 regjsparser: 0.10.0 - safe-regex: 2.1.1 - semver: 7.5.0 + semver: 7.5.4 strip-indent: 3.0.0 dev: true @@ -2598,6 +2553,12 @@ packages: get-intrinsic: 1.2.0 dev: true + /get-tsconfig@4.7.2: + resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} + dependencies: + resolve-pkg-maps: 1.0.0 + dev: true + /glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -2656,7 +2617,7 @@ packages: array-union: 2.1.0 dir-glob: 3.0.1 fast-glob: 3.2.12 - ignore: 5.2.0 + ignore: 5.2.4 merge2: 1.4.1 slash: 3.0.0 dev: true @@ -2758,11 +2719,6 @@ packages: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: false - /ignore@5.2.0: - resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==} - engines: {node: '>= 4'} - dev: true - /ignore@5.2.4: resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} engines: {node: '>= 4'} @@ -3558,13 +3514,6 @@ packages: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} dev: true - /json5@1.0.2: - resolution: {integrity: sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==} - hasBin: true - dependencies: - minimist: 1.2.8 - dev: true - /json5@2.2.3: resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} engines: {node: '>=6'} @@ -3654,10 +3603,6 @@ packages: resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} dev: false - /lodash@4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: true - /log-symbols@5.1.0: resolution: {integrity: sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA==} engines: {node: '>=12'} @@ -3746,10 +3691,6 @@ packages: brace-expansion: 1.1.11 dev: true - /minimist@1.2.8: - resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - dev: true - /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true @@ -4248,6 +4189,10 @@ packages: engines: {node: '>=8'} dev: true + /resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + dev: true + /resolve.exports@2.0.2: resolution: {integrity: sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==} engines: {node: '>=10'} @@ -4275,7 +4220,7 @@ packages: resolution: {integrity: sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==} hasBin: true dependencies: - is-core-module: 2.12.0 + is-core-module: 2.13.1 path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 dev: true @@ -4318,12 +4263,6 @@ packages: is-regex: 1.1.4 dev: true - /safe-regex@2.1.1: - resolution: {integrity: sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==} - dependencies: - regexp-tree: 0.1.27 - dev: true - /semver@5.7.1: resolution: {integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==} hasBin: true @@ -4334,14 +4273,6 @@ packages: hasBin: true dev: true - /semver@7.5.0: - resolution: {integrity: sha512-+XC0AD/R7Q2mPSRuy2Id0+CGTZ98+8f+KvwirxOKIEyid+XSx6HbC63p+O4IndTHuX5Z+JxQ0TghCkO5Cg/2HA==} - engines: {node: '>=10'} - hasBin: true - dependencies: - lru-cache: 6.0.0 - dev: true - /semver@7.5.4: resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} engines: {node: '>=10'} @@ -4508,7 +4439,7 @@ packages: es-abstract: 1.21.2 get-intrinsic: 1.2.0 has-symbols: 1.0.3 - internal-slot: 1.0.3 + internal-slot: 1.0.5 regexp.prototype.flags: 1.5.0 side-channel: 1.0.4 dev: true @@ -4702,15 +4633,6 @@ packages: typescript: 5.2.2 dev: true - /tsconfig-paths@3.14.2: - resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} - dependencies: - '@types/json5': 0.0.29 - json5: 1.0.2 - minimist: 1.2.8 - strip-bom: 3.0.0 - dev: true - /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true From bfd746b4de7d22ea843b53c075a6309459c26d7d Mon Sep 17 00:00:00 2001 From: mizdra Date: Tue, 7 Nov 2023 01:09:41 +0900 Subject: [PATCH 4/6] fix lint errors --- src/util/eslint.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/eslint.ts b/src/util/eslint.ts index 3654af36..3daec462 100644 --- a/src/util/eslint.ts +++ b/src/util/eslint.ts @@ -18,7 +18,8 @@ export function scanUsedPluginsFromResults(results: ESLint.LintResult[]): string const parts = ruleId.split('/'); if (parts.length === 1) return undefined; // ex: 'rule-a' if (parts.length === 2) return parts[0]; // ex: 'plugin/rule-a' - if (parts.length === 3) return `${parts[0]}/${parts[1]}`; // ex: '@scoped/plugin/rule-a' + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + if (parts.length === 3) return `${parts[0]!}/${parts[1]!}`; // ex: '@scoped/plugin/rule-a' return undefined; // invalid ruleId }) // plugins: string[] .filter(notEmpty); From e75478408827d649831374aca9277d7dfea2e078 Mon Sep 17 00:00:00 2001 From: mizdra Date: Wed, 8 Nov 2023 22:01:31 +0900 Subject: [PATCH 5/6] pnpm i @jest/globals --- package.json | 1 + pnpm-lock.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/package.json b/package.json index 1b21575e..cca64997 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "devDependencies": { "@babel/core": "^7.23.2", "@babel/preset-typescript": "^7.23.2", + "@jest/globals": "^29.7.0", "@jest/types": "^29.6.3", "@mizdra/eslint-config-mizdra": "2.1.0-alpha.0", "@mizdra/prettier-config-mizdra": "^1.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2978cfcd..1ab1161e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,6 +52,9 @@ devDependencies: '@babel/preset-typescript': specifier: ^7.23.2 version: 7.23.2(@babel/core@7.23.2) + '@jest/globals': + specifier: ^29.7.0 + version: 29.7.0 '@jest/types': specifier: ^29.6.3 version: 29.6.3 From c5d45746de6a5585d20719e4aa1cbe1ee4d27e94 Mon Sep 17 00:00:00 2001 From: mizdra Date: Wed, 8 Nov 2023 22:01:49 +0900 Subject: [PATCH 6/6] fix failed tests --- src/__snapshots__/core.test.ts.snap | 14 +++++++------- src/core.test.ts | 14 +++++++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/__snapshots__/core.test.ts.snap b/src/__snapshots__/core.test.ts.snap index 946941cc..5130ab61 100644 --- a/src/__snapshots__/core.test.ts.snap +++ b/src/__snapshots__/core.test.ts.snap @@ -620,21 +620,21 @@ exports[`Core printSummaryOfResults 1`] = ` ╔═════════════════════════════╤═══════╤═════════╤════════════╤═════════════════╗ ║ Rule │ Error │ Warning │ is fixable │ has suggestions ║ ╟─────────────────────────────┼───────┼─────────┼────────────┼─────────────────╢ -║ ]8;;https://eslint.org/docs/latest/rules/semisemi]8;; │ 14 │ 1 │ 15 │ 0 ║ +║ semi │ 14 │ 1 │ 15 │ 0 ║ ╟─────────────────────────────┼───────┼─────────┼────────────┼─────────────────╢ -║ ]8;;https://github.com/import-js/eslint-plugin-import/blob/v2.27.5/docs/rules/order.mdimport/order]8;; │ 3 │ 0 │ 3 │ 0 ║ +║ import/order │ 3 │ 0 │ 3 │ 0 ║ ╟─────────────────────────────┼───────┼─────────┼────────────┼─────────────────╢ -║ ]8;;https://eslint.org/docs/latest/rules/prefer-constprefer-const]8;; │ 4 │ 0 │ 4 │ 0 ║ +║ ]8;;https://example.comprefer-const]8;; │ 4 │ 0 │ 4 │ 0 ║ ╟─────────────────────────────┼───────┼─────────┼────────────┼─────────────────╢ -║ ]8;;https://eslint.org/docs/latest/rules/no-unused-varsno-unused-vars]8;; │ 11 │ 0 │ 0 │ 0 ║ +║ no-unused-vars │ 11 │ 0 │ 0 │ 0 ║ ╟─────────────────────────────┼───────┼─────────┼────────────┼─────────────────╢ ║ ban-exponentiation-operator │ 2 │ 0 │ 0 │ 0 ║ ╟─────────────────────────────┼───────┼─────────┼────────────┼─────────────────╢ -║ ]8;;https://eslint.org/docs/latest/rules/no-useless-escapeno-useless-escape]8;; │ 5 │ 0 │ 0 │ 5 ║ +║ no-useless-escape │ 5 │ 0 │ 0 │ 5 ║ ╟─────────────────────────────┼───────┼─────────┼────────────┼─────────────────╢ -║ ]8;;https://eslint.org/docs/latest/rules/no-unsafe-negationno-unsafe-negation]8;; │ 5 │ 0 │ 0 │ 5 ║ +║ no-unsafe-negation │ 5 │ 0 │ 0 │ 5 ║ ╟─────────────────────────────┼───────┼─────────┼────────────┼─────────────────╢ -║ ]8;;https://eslint.org/docs/latest/rules/arrow-body-stylearrow-body-style]8;; │ 12 │ 0 │ 12 │ 0 ║ +║ arrow-body-style │ 12 │ 0 │ 12 │ 0 ║ ╚═════════════════════════════╧═══════╧═════════╧════════════╧═════════════════╝ " `; diff --git a/src/core.test.ts b/src/core.test.ts index 7e82971b..e57485d9 100644 --- a/src/core.test.ts +++ b/src/core.test.ts @@ -1,11 +1,10 @@ import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; +import { jest } from '@jest/globals'; import { ESLint, Linter } from 'eslint'; import { Core, DEFAULT_BASE_CONFIG } from './core.js'; import { cleanupFixturesCopy, getSnapshotOfChangedFiles, setupFixturesCopy } from './test-util/fixtures.js'; -const testIf = (condition: boolean) => (condition ? test : test.skip); - const cwd = join(dirname(fileURLToPath(import.meta.url)), '..'); // For some reason, the test fails if `formatterName === 'codeframe'`. // So here we overwrite it with `formatterName === 'eslint-formatter-codeframe'`. @@ -129,8 +128,17 @@ describe('Core', () => { }); }); // This test fails because the documentation url format is not supported in eslint 7.x.x and 8.0.0. Therefore, ignore this test. - testIf(!ESLint.version.startsWith('7.') && ESLint.version !== '8.0.0')('printSummaryOfResults', async () => { + test('printSummaryOfResults', async () => { const results = await core.lint(); + jest.spyOn(ESLint.prototype, 'getRulesMetaForResults').mockImplementationOnce(() => { + return { + 'prefer-const': { + docs: { + url: 'https://example.com', + }, + }, + }; + }); expect(core.formatResultSummary(results)).toMatchSnapshot(); }); test('printDetailsOfResults', async () => {