Skip to content

Commit

Permalink
fix: missing import recognise tsx extension
Browse files Browse the repository at this point in the history
  • Loading branch information
neviaumi committed May 10, 2023
1 parent 49d3ee7 commit ddba8e5
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/eslint-plugin-n.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util/is-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const path = require("path")

const typescriptExtensions = [".ts", ".cts", ".mts"]
const typescriptExtensions = [".ts", ".tsx", ".cts", ".mts"]

/**
* Determine if the context source file is typescript.
Expand Down
2 changes: 2 additions & 0 deletions lib/util/map-typescript-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ const mapping = {
".ts": ".js",
".cts": ".cjs",
".mts": ".mjs",
".tsx": ".jsx",
}

const reverseMapping = {
".js": ".ts",
".cjs": ".cts",
".mjs": ".mts",
".jsx": ".tsx",
}

/**
Expand Down
Empty file.
Empty file added tests/fixtures/no-missing/e.tsx
Empty file.
5 changes: 5 additions & 0 deletions tests/lib/rules/file-extension-in-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ new RuleTester({
code: "import './c.mjs'",
options: ["always"],
},
{
filename: fixture("test.tsx"),
code: "import './d.jsx'",
options: ["always"],
},
{
filename: fixture("test.js"),
code: "import './a'",
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/no-missing-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ ruleTester.run("no-missing-import", rule, {
filename: fixture("test.js"),
code: "import mocha from 'mocha!foo?a=b&c=d';",
},
{
filename: fixture("test.tsx"),
code: "import a from './e.jsx';",
},

// Ignores it if the filename is unknown.
"import abc from 'no-exist-package-0';",
Expand Down

0 comments on commit ddba8e5

Please sign in to comment.