diff --git a/.eslintrc.js b/.eslintrc.js index 93a919dc..cc846da8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -40,7 +40,7 @@ module.exports = { files: ['**/*.ts?(x)'], parser: '@typescript-eslint/parser', parserOptions: { - project: './tsconfig.eslint.json', + projectService: true, tsconfigRootDir: __dirname, }, extends: [ diff --git a/.gitignore b/.gitignore index 776666b4..f431e202 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,6 @@ yarn-error.log # Ignore locks other than pnpm package-lock.json yarn.lock + +# Build +*.tsbuildinfo \ No newline at end of file diff --git a/index.d.ts b/index.d.ts index 1f4e5e7e..d8fd6e83 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,9 @@ +/** + * Keeping types here instead of generating types from the plugin for the same reasons + * as typescript-eslint: + * https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/rules.d.ts + */ + import type { Linter, Rule } from 'eslint'; declare const plugin: { diff --git a/lib/index.ts b/lib/index.ts index bb6f4db6..241f1474 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -5,6 +5,7 @@ import rules from './rules'; import { SupportedTestingFramework } from './utils'; // we can't natively import package.json as tsc will copy it into dist/ +// (same as typescript-eslint https://github.com/typescript-eslint/typescript-eslint/blob/7defffef8fe77387a22dbd5a538ff4cafcf81253/packages/eslint-plugin/src/index.ts#L18) const { name: packageName, version: packageVersion, @@ -16,6 +17,7 @@ const plugin = { name: packageName, version: packageVersion, }, + // TODO: improve this // ugly cast for now to keep TypeScript happy since // we don't have types for flat config yet configs: {} as Record< diff --git a/package.json b/package.json index 4ba0d923..98a581c9 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "types": "index.d.ts", "scripts": { "prebuild": "del-cli dist", - "build": "tsc", + "build": "tsc -b tsconfig.build.json", "generate-all": "pnpm run --parallel \"/^generate:.*/\"", "generate-all:check": "pnpm run generate-all && git diff --exit-code", "generate:configs": "ts-node tools/generate-configs", diff --git a/tests/lib/test-utils.ts b/tests/lib/test-utils.ts index c65ac6c1..a88c1950 100644 --- a/tests/lib/test-utils.ts +++ b/tests/lib/test-utils.ts @@ -1,5 +1,6 @@ import tsESLintParser from '@typescript-eslint/parser'; import { RuleTester, RunTests } from '@typescript-eslint/rule-tester'; +import { TSUtils } from '@typescript-eslint/utils'; import { TestingLibraryPluginRuleModule } from '../../lib/utils'; @@ -11,8 +12,9 @@ class TestingLibraryRuleTester extends RuleTester { run( ruleName: string, rule: TestingLibraryPluginRuleModule, - { invalid, valid }: RunTests + test: RunTests, TSUtils.NoInfer> ): void { + const { valid, invalid } = test; const finalValid = valid.map((testCase) => { if (typeof testCase === 'string') { return { diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..e14bc3e5 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": false, + "declarationMap": false, + "outDir": "./dist", + "rootDir": "./lib" + }, + "include": ["lib", "*.d.ts"] +} diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json deleted file mode 100644 index b0a6dfc7..00000000 --- a/tsconfig.eslint.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["**/*.ts", "**/*.js"] -} diff --git a/tsconfig.json b/tsconfig.json index b4fb3559..b2b02aba 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,20 +1,22 @@ { "compilerOptions": { + "rootDir": ".", "strict": true, - "target": "ES2019", + "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", - "lib": ["ES2019"], + "lib": ["ES2023"], "esModuleInterop": true, "skipLibCheck": true, "resolveJsonModule": true, "moduleDetection": "force", "isolatedModules": true, "removeComments": true, + "sourceMap": true, + "declaration": true, + "declarationMap": true, // TODO: turn it on - "noUncheckedIndexedAccess": false, - "outDir": "dist", - "sourceMap": false + "noUncheckedIndexedAccess": false }, - "include": ["./lib/**/*.ts"] + "include": ["lib", "tests", "tools", "*.d.ts"] }