Skip to content

Commit 86224ce

Browse files
committed
update
1 parent 66a1d70 commit 86224ce

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

src/index.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,20 @@ export function parseForESLint(
6464
result = parseScript(code, {
6565
...options,
6666
ecmaVersion: options.ecmaVersion || DEFAULT_ECMA_VERSION,
67-
parser: getScriptParser(options.parser, () =>
68-
(path.extname(options.filePath || "unknown.js") || "")
67+
parser: getScriptParser(options.parser, () => {
68+
const ext = (
69+
path
70+
.extname(options.filePath || "unknown.js")
71+
.toLowerCase() || ""
72+
)
6973
// remove dot
70-
.slice(1),
71-
),
74+
.slice(1)
75+
if (/^[jt]sx$/u.test(ext)) {
76+
return [ext, ext.slice(0, -1)]
77+
}
78+
79+
return ext
80+
}),
7281
})
7382
document = null
7483
locationCalculator = null

test/fixtures/typed.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
interface Data {
2+
greeting: string
3+
}
4+
5+
export default {
6+
data(): Data {
7+
return {greeting: "Hello"}
8+
},
9+
}

test/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ describe("Basic tests", () => {
307307
},
308308
useEslintrc: false,
309309
})
310-
const report = await cli.lintFiles(["typed.ts"])
311-
const messages = report[0].messages
310+
const report = await cli.lintFiles(["typed.ts", "typed.tsx"])
312311

313-
assert.deepStrictEqual(messages, [])
312+
assert.deepStrictEqual(report[0].messages, [])
313+
assert.deepStrictEqual(report[1].messages, [])
314314
})
315315
}
316316
})

0 commit comments

Comments
 (0)