[eslint-plugin] fix ts-modules-only-named
invalid test cases
#30924
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There's some change in
typescript-eslint
that breaks some eslint test cases.Previously when running tests, in a rule's
create()
method, we get a relativepath for
context.filename
, and when we pass a setting of{ main: "src/test.ts" }
in rule tester option, the two were considered the same file,therefore the following condition check failed, and we continue to report error
for default exports.
azure-sdk-for-js/common/tools/eslint-plugin-azure-sdk/src/rules/ts-modules-only-named.ts
Line 31 in 6dd8b58
After the upgrade,
context.filename
now contains the full path, the filesrc/test.ts
in our test fixture has a full path of/.../common/tools/eslint-plugin-azure-sdk/tests/fixture/src/test.ts
. It is notconsidered the same file as the passed settings implies
/.../common/tools/eslint-plugin-azure-sdk/src/test.ts
when we run the tests.So we return earlier instead of going to check for default exports.
This is not an issue in real scenario where we have settings of
{ main: "src/index.ts" }
, which would match the full path of the file we are lintingwhen we run
eslint
from a package directory.This PR fixes the test by passing
tests/fixture/src/test.ts
in the settings sothat it matches the full path of
context.filename
we get increate()
.