-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: Requires Node@^18.18.0 || ^20.9.0 || >=21.1.0 BREAKING CHANGE: Requires ESLint `^8.57.0`, or `^9.0.0` Co-authored-by: Michaël De Boey <[email protected]>
- Loading branch information
1 parent
3615223
commit 13645b7
Showing
30 changed files
with
665 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Guide: migrating to v7 | ||
|
||
If you are not on v6 yet, we recommend first following the [v6 migration guide](docs/migration-guides/v6.md). | ||
|
||
## Overview | ||
|
||
- **(Breaking)** Supported versions of Node.js have been updated to `^18.18.0`, `^20.9.0`, or `>=21.1.0`, matching ESLint. | ||
- **(Breaking)** Supported versions of ESLint have been updated to `^8.57.0`, or `^9.0.0`. | ||
- Full support for ESLint v9 (v8 still compatible) and typescript-eslint v8 | ||
|
||
## Steps to upgrade | ||
|
||
1. Make sure you are using a supported version of Node.js, and upgrade if not. | ||
2. Make sure you are using a supported version of ESLint, and upgrade if not. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
import { join } from 'path'; | ||
|
||
import { type TSESLint } from '@typescript-eslint/utils'; | ||
import type { TSESLint } from '@typescript-eslint/utils'; | ||
|
||
import { | ||
importDefault, | ||
SUPPORTED_TESTING_FRAMEWORKS, | ||
SupportedTestingFramework, | ||
} from '../utils'; | ||
|
||
export type LinterConfigRules = Pick<Required<TSESLint.Linter.Config>, 'rules'>; | ||
|
||
const configsDir = __dirname; | ||
|
||
const getConfigForFramework = (framework: SupportedTestingFramework) => | ||
importDefault<LinterConfigRules>(join(configsDir, framework)); | ||
importDefault<TSESLint.SharedConfig.RulesRecord>(join(configsDir, framework)); | ||
|
||
export default SUPPORTED_TESTING_FRAMEWORKS.reduce( | ||
(allConfigs, framework) => ({ | ||
...allConfigs, | ||
[framework]: getConfigForFramework(framework), | ||
}), | ||
{} | ||
) as Record<SupportedTestingFramework, LinterConfigRules>; | ||
) as Record<SupportedTestingFramework, TSESLint.SharedConfig.RulesRecord>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,37 @@ | ||
import { ESLintUtils, TSESLint } from '@typescript-eslint/utils'; | ||
import { ESLintUtils } from '@typescript-eslint/utils'; | ||
|
||
import { getDocsUrl, TestingLibraryRuleMeta } from '../utils'; | ||
import { getDocsUrl, TestingLibraryPluginDocs } from '../utils'; | ||
|
||
import { | ||
DetectionOptions, | ||
detectTestingLibraryUtils, | ||
EnhancedRuleCreate, | ||
} from './detect-testing-library-utils'; | ||
|
||
export function createTestingLibraryRule< | ||
export const createTestingLibraryRule = < | ||
TOptions extends readonly unknown[], | ||
TMessageIds extends string, | ||
TRuleListener extends TSESLint.RuleListener = TSESLint.RuleListener, | ||
>({ | ||
create, | ||
detectionOptions = {}, | ||
meta, | ||
...remainingConfig | ||
}: Readonly<{ | ||
name: string; | ||
meta: TestingLibraryRuleMeta<TMessageIds, TOptions>; | ||
defaultOptions: Readonly<TOptions>; | ||
detectionOptions?: Partial<DetectionOptions>; | ||
create: EnhancedRuleCreate<TOptions, TMessageIds, TRuleListener>; | ||
}>): TSESLint.RuleModule<TMessageIds, TOptions> { | ||
// eslint-disable-next-line new-cap | ||
return ESLintUtils.RuleCreator(getDocsUrl)({ | ||
}: Readonly< | ||
Omit< | ||
ESLintUtils.RuleWithMetaAndName< | ||
TOptions, | ||
TMessageIds, | ||
TestingLibraryPluginDocs<TOptions> | ||
>, | ||
'create' | ||
> & { | ||
create: EnhancedRuleCreate<TMessageIds, TOptions>; | ||
detectionOptions?: Partial<DetectionOptions>; | ||
} | ||
>) => | ||
ESLintUtils.RuleCreator<TestingLibraryPluginDocs<TOptions>>(getDocsUrl)({ | ||
...remainingConfig, | ||
create: detectTestingLibraryUtils<TOptions, TMessageIds, TRuleListener>( | ||
create: detectTestingLibraryUtils<TMessageIds, TOptions>( | ||
create, | ||
detectionOptions | ||
), | ||
meta: { | ||
...meta, | ||
docs: { | ||
...meta.docs, | ||
// We're using our own recommendedConfig meta to tell our build tools | ||
// if the rule is recommended on a config basis | ||
recommended: false, | ||
}, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
import { readdirSync } from 'fs'; | ||
import { join, parse } from 'path'; | ||
|
||
import { TSESLint } from '@typescript-eslint/utils'; | ||
|
||
import { importDefault, TestingLibraryRuleMeta } from '../utils'; | ||
|
||
type RuleModule = TSESLint.RuleModule<string, unknown[]> & { | ||
meta: TestingLibraryRuleMeta<string, unknown[]> & { | ||
recommended: false; | ||
}; | ||
}; | ||
import { importDefault, TestingLibraryPluginRuleModule } from '../utils'; | ||
|
||
const rulesDir = __dirname; | ||
const excludedFiles = ['index']; | ||
|
||
export default readdirSync(rulesDir) | ||
.map((rule) => parse(rule).name) | ||
.filter((ruleName) => !excludedFiles.includes(ruleName)) | ||
.reduce<Record<string, RuleModule>>( | ||
.reduce<Record<string, TestingLibraryPluginRuleModule<string, unknown[]>>>( | ||
(allRules, ruleName) => ({ | ||
...allRules, | ||
[ruleName]: importDefault<RuleModule>(join(rulesDir, ruleName)), | ||
[ruleName]: importDefault< | ||
TestingLibraryPluginRuleModule<string, unknown[]> | ||
>(join(rulesDir, ruleName)), | ||
}), | ||
{} | ||
); |
Oops, something went wrong.