@@ -34,13 +34,63 @@ const VITEST_COMPATIBLE_JEST_RULES: phf::Set<&'static str> = phf::phf_set! {
3434 "valid-expect" ,
3535} ;
3636
37+ // List of Eslint rules that have Typescript equivalents.
38+ const TYPESCRIPT_COMPATIBLE_ESLINT_RULES : phf:: Set < & ' static str > = phf:: phf_set! {
39+ "class-methods-use-this" ,
40+ "default-param-last" ,
41+ "init-declarations" ,
42+ "max-params" ,
43+ "no-array-constructor" ,
44+ "no-dupe-class-members" ,
45+ "no-empty-function" ,
46+ "no-invalid-this" ,
47+ "no-loop-func" ,
48+ "no-loss-of-precision" ,
49+ "no-magic-numbers" ,
50+ "no-redeclare" ,
51+ "no-restricted-imports" ,
52+ "no-shadow" ,
53+ "no-unused-expressions" ,
54+ "no-unused-vars" ,
55+ "no-use-before-define" ,
56+ "no-useless-constructor" ,
57+
58+ // these rules are equivalents, but not supported
59+ // "block-spacing",
60+ // "brace-style",
61+ // "comma-dangle",
62+ // "comma-spacing",
63+ // "func-call-spacing",
64+ // "indent",
65+ // "key-spacing",
66+ // "keyword-spacing",
67+ // "lines-around-comment",
68+ // "lines-between-class-members",
69+ // "no-extra-parens",
70+ // "no-extra-semi",
71+ // "object-curly-spacing",
72+ // "padding-line-between-statements",
73+ // "quotes",
74+ // "semi",
75+ // "space-before-blocks",
76+ // "space-before-function-paren",
77+ // "space-infix-ops",
78+ } ;
79+
3780/// Check if the Jest rule is adapted to Vitest.
3881/// Many Vitest rule are essentially ports of Jest plugin rules with minor modifications.
3982/// For these rules, we use the corresponding jest rules with some adjustments for compatibility.
4083pub fn is_jest_rule_adapted_to_vitest ( rule_name : & str ) -> bool {
4184 VITEST_COMPATIBLE_JEST_RULES . contains ( rule_name)
4285}
4386
87+ /// Check if the Eslint rule is adapted to Typescript.
88+ /// Many Typescript rule are essentially ports of Eslint plugin rules with minor modifications.
89+ /// For these rules, we use the corresponding eslint rules with some adjustments for compatibility.
90+ pub fn is_eslint_rule_adapted_to_typescript ( rule_name : & str ) -> bool {
91+ TYPESCRIPT_COMPATIBLE_ESLINT_RULES . contains ( rule_name)
92+ }
93+
4494pub fn read_to_string ( path : & Path ) -> io:: Result < String > {
4595 // `simdutf8` is faster than `std::str::from_utf8` which `fs::read_to_string` uses internally
4696 let bytes = std:: fs:: read ( path) ?;
0 commit comments