Skip to content

Commit d1100cf

Browse files
authored
chore: fix no-confusing-void-expression (#174)
1 parent 96db70a commit d1100cf

File tree

6 files changed

+64
-12
lines changed

6 files changed

+64
-12
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,8 @@
5151
"engines": {
5252
"pnpm": ">=10"
5353
},
54-
"files": []
54+
"files": [],
55+
"dependencies": {
56+
"@types/react": "^19.1.9"
57+
}
5558
}
Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
{
22
"compilerOptions": {
3-
"strictNullChecks": true,
4-
"isolatedModules": true,
5-
"jsx": "preserve"
3+
"jsx": "preserve",
4+
"target": "es5",
5+
"module": "commonjs",
6+
"strict": true,
7+
"esModuleInterop": true,
8+
"lib": [
9+
"es2015",
10+
"es2017",
11+
"esnext"
12+
],
13+
"experimentalDecorators": true,
614
},
715
"include": [
8-
"src/**/*.ts"
16+
"file.ts",
17+
"consistent-type-exports.ts",
18+
"deprecated.ts",
19+
"mixed-enums-decl.ts",
20+
"react.tsx",
21+
"var-declaration.ts",
22+
"errors.ts",
23+
"switch-exhaustiveness-check.ts"
924
]
1025
}
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{
22
"compilerOptions": {
3-
"strictNullChecks": true,
4-
"jsx": "preserve"
3+
"jsx": "preserve",
4+
"target": "es5",
5+
"module": "commonjs",
6+
"strict": true,
7+
"esModuleInterop": true,
8+
"lib": [
9+
"es2015",
10+
"es2017",
11+
"esnext"
12+
],
13+
"experimentalDecorators": true
514
},
615
"include": [
7-
"src/virtual.ts"
16+
"src/virtual.tsx",
17+
"src/virtual.ts",
18+
819
]
920
}

packages/rslint-test-tools/tests/typescript-eslint/rules/no-confusing-void-expression.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ const test: Foo = () => console.log('foo');
298298
},
299299
{
300300
code: 'const foo = <button onClick={() => console.log()} />;',
301-
// FIXME: it seems jsx is not supported in tsgo yet
302-
skip: true,
303301
languageOptions: {
304302
parserOptions: {
305303
ecmaFeatures: {

packages/rule-tester/src/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class RuleTester {
147147
this.options.languageOptions?.parserOptions?.tsconfigRootDir ||
148148
process.cwd();
149149
const config = path.resolve(cwd, './rslint.json');
150-
let virtual_entry = path.resolve(cwd, 'src/virtual.ts');
150+
151151
// test whether case has only
152152
let hasOnly =
153153
cases.valid.some(x => {
@@ -157,6 +157,7 @@ export class RuleTester {
157157
return false;
158158
}
159159
}) || cases.invalid.some(x => x.only);
160+
let virtual_entry = path.resolve(cwd, 'src/virtual.ts');
160161
test('valid', async () => {
161162
for (const validCase of cases.valid) {
162163
if (typeof validCase === 'object' && validCase.skip) {
@@ -172,10 +173,17 @@ export class RuleTester {
172173
}
173174
const code =
174175
typeof validCase === 'string' ? validCase : validCase.code;
176+
const isJSX =
177+
typeof validCase === 'string'
178+
? false
179+
: validCase.languageOptions?.parserOptions?.ecmaFeatures?.jsx;
175180

176181
const options =
177182
typeof validCase === 'string' ? [] : validCase.options || [];
178-
183+
let virtual_entry = path.resolve(
184+
cwd,
185+
isJSX ? 'src/virtual.tsx' : 'src/virtual.ts',
186+
);
179187
// workaround for this hardcoded path https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/tests/rules/no-floating-promises.test.ts#L712
180188
if (Array.isArray(options)) {
181189
for (const opt of options) {
@@ -230,6 +238,7 @@ export class RuleTester {
230238
[ruleName]: options,
231239
},
232240
});
241+
233242
expect(diags).toMatchSnapshot();
234243

235244
assert(

pnpm-lock.yaml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)