Skip to content

Commit

Permalink
feat(import-target): Add resolution error reason
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed May 6, 2024
1 parent f9e454d commit dc5f781
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/eslint-rule-tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,18 @@ exports.RuleTester = function (config = defaultConfig) {
)

const ruleTester = new exports.FlatRuleTester(config)
const $run = ruleTester.run.bind(ruleTester)
ruleTester.run = function (name, rule, tests) {
tests.valid = tests.valid.filter(shouldRun)
tests.invalid = tests.invalid.filter(shouldRun)

$run(name, rule, tests)
}
return ruleTester
}

// support skip in tests
function shouldRun(item) {
const skip = typeof item === "string" ? false : item.skip
return skip === void 0 || skip === false
}
6 changes: 6 additions & 0 deletions tests/lib/rules/no-missing-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const tsReactExtensionMap = [
[".tsx", ".js"],
]

const isCaseSensitiveFileSystem =
process.platform === "linux" ||
process.platform === "freebsd" ||
process.platform === "openbsd"

/**
* Makes a file path to a fixture.
* @param {string} name - A name.
Expand Down Expand Up @@ -427,6 +432,7 @@ ruleTester.run("no-missing-import", rule, {
filename: fixture("test.js"),
code: "import a from './A.js';",
errors: cantResolve("./A.js"),
skip: !isCaseSensitiveFileSystem,
},

{
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/no-missing-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const tsReactExtensionMap = [
[".tsx", ".js"],
]

const isCaseSensitiveFileSystem =
process.platform === "linux" ||
process.platform === "freebsd" ||
process.platform === "openbsd"

/**
* Makes a file path to a fixture.
* @param {string} name - A name.
Expand Down Expand Up @@ -396,6 +401,7 @@ ruleTester.run("no-missing-require", rule, {
filename: fixture("test.js"),
code: "require('./A');",
errors: cantResolve("./A"),
skip: !isCaseSensitiveFileSystem,
},

// require.resolve
Expand Down

0 comments on commit dc5f781

Please sign in to comment.