File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { RuleTester } from "@typescript-eslint/rule-tester" ;
2- import migration from "./index.ts" ;
32import parser from "@typescript-eslint/parser" ;
43import manifest from "./package.json" with { type : "json" } ;
54
@@ -11,10 +10,12 @@ const tester = new RuleTester({
1110 languageOptions : { parser } ,
1211} ) ;
1312
14- const ruleName = `v${ manifest . version . split ( "." ) [ 0 ] } ` ;
15- const theRule = migration . rules [ ruleName as keyof typeof migration . rules ] ;
13+ describe ( "Migration" , async ( ) => {
14+ vi . stubEnv ( "TSDOWN_VERSION" , manifest . version ) ;
15+ const { default : migration } = await import ( "./index.ts" ) ;
16+ const ruleName = `v${ manifest . version . split ( "." ) [ 0 ] } ` ;
17+ const theRule = migration . rules [ ruleName as keyof typeof migration . rules ] ;
1618
17- describe ( "Migration" , ( ) => {
1819 test ( "should consist of one rule being the major version of the package" , ( ) => {
1920 expect ( migration . rules ) . toHaveProperty ( ruleName ) ;
2021 expect ( migration ) . toMatchSnapshot ( ) ;
Original file line number Diff line number Diff line change @@ -38,7 +38,10 @@ const listen = <
3838 { } ,
3939 ) ;
4040
41- const v25 = ESLintUtils . RuleCreator . withoutDocs ( {
41+ // eslint-disable-next-line no-restricted-syntax -- substituted by TSDOWN and vitest
42+ const ruleName = `v${ process . env . TSDOWN_VERSION ! . split ( "." ) [ 0 ] } ` ;
43+
44+ const theRule = ESLintUtils . RuleCreator . withoutDocs ( {
4245 meta : {
4346 type : "problem" ,
4447 fixable : "code" ,
@@ -90,5 +93,5 @@ const v25 = ESLintUtils.RuleCreator.withoutDocs({
9093} ) ;
9194
9295export default {
93- rules : { v25 } ,
96+ rules : { [ ruleName ] : theRule } as Record < `v${ number } ` , typeof theRule > ,
9497} satisfies TSESLint . Linter . Plugin ;
Original file line number Diff line number Diff line change 11import { defineConfig } from "tsdown" ;
2+ import manifest from "./package.json" with { type : "json" } ;
23
34export default defineConfig ( {
45 entry : "index.ts" ,
56 minify : true ,
67 skipNodeModulesBundle : true ,
78 attw : { profile : "esmOnly" , level : "error" } ,
9+ define : {
10+ "process.env.TSDOWN_VERSION" : `"${ manifest . version } "` , // used by ruleName
11+ } ,
812} ) ;
You can’t perform that action at this time.
0 commit comments