-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: migrate to createRuleTestCaseFunction
#184
base: master
Are you sure you want to change the base?
Changes from all commits
92d6ab4
3e2f5f8
17b6ccf
6c630aa
249dbfb
bd6e8ce
f0b3e64
e0e822d
1876419
b130ac4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"eslint-plugin-import-x": patch | ||
--- | ||
|
||
fix(first): add missing value in options type | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -24,7 +24,7 @@ jobs: | |||||||||||||||||||||||||
eslint: | ||||||||||||||||||||||||||
- '8.56' | ||||||||||||||||||||||||||
- '8' | ||||||||||||||||||||||||||
- '9' | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yesterday the task was working It seems an issue with I assume that the following steps in CI workflows ends up installing the last version of eslint-plugin-import-x/.github/workflows/ci.yml Lines 56 to 63 in 14fc608
eslint-plugin-import-x/.github/workflows/ci.yml Lines 24 to 27 in 14fc608
Replacing I just want to report that on the failing CI the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that the issue comes from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, and the same issue is affecting |
||||||||||||||||||||||||||
- '9.14' | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
include: | ||||||||||||||||||||||||||
- executeLint: true | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,20 @@ import path from 'node:path' | |
|
||
import { RuleTester as TSESLintRuleTester } from '@typescript-eslint/rule-tester' | ||
|
||
import { test, SYNTAX_CASES, parsers } from '../utils' | ||
import { | ||
createRuleTestCaseFunction, | ||
SYNTAX_VALID_CASES, | ||
parsers, | ||
} from '../utils' | ||
import type { RunTests } from '../utils' | ||
|
||
import rule from 'eslint-plugin-import-x/rules/default' | ||
import { CASE_SENSITIVE_FS } from 'eslint-plugin-import-x/utils' | ||
|
||
const ruleTester = new TSESLintRuleTester() | ||
|
||
const test = createRuleTestCaseFunction<typeof rule>() | ||
|
||
ruleTester.run('default', rule, { | ||
valid: [ | ||
test({ | ||
|
@@ -123,7 +130,7 @@ ruleTester.run('default', rule, { | |
}, | ||
}), | ||
|
||
...SYNTAX_CASES, | ||
...(SYNTAX_VALID_CASES as RunTests<typeof rule>['valid']), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to create a minimal type of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is already done on
but this is will be never assignable to something that is rule specific like in these scenario where the |
||
], | ||
|
||
invalid: [ | ||
|
@@ -138,9 +145,10 @@ ruleTester.run('default', rule, { | |
code: 'import baz from "./named-exports";', | ||
errors: [ | ||
{ | ||
message: | ||
'No default export found in imported module "./named-exports".', | ||
type: 'ImportDefaultSpecifier', | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './named-exports', | ||
}, | ||
}, | ||
], | ||
}), | ||
|
@@ -149,31 +157,64 @@ ruleTester.run('default', rule, { | |
test({ | ||
code: 'export baz from "./named-exports"', | ||
languageOptions: { parser: require(parsers.BABEL) }, | ||
errors: ['No default export found in imported module "./named-exports".'], | ||
errors: [ | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './named-exports', | ||
}, | ||
}, | ||
], | ||
}), | ||
test({ | ||
code: 'export baz, { bar } from "./named-exports"', | ||
languageOptions: { parser: require(parsers.BABEL) }, | ||
errors: ['No default export found in imported module "./named-exports".'], | ||
errors: [ | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './named-exports', | ||
}, | ||
}, | ||
], | ||
}), | ||
test({ | ||
code: 'export baz, * as names from "./named-exports"', | ||
languageOptions: { parser: require(parsers.BABEL) }, | ||
errors: ['No default export found in imported module "./named-exports".'], | ||
errors: [ | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './named-exports', | ||
}, | ||
}, | ||
], | ||
}), | ||
// exports default from a module with no default | ||
test({ | ||
code: 'import twofer from "./broken-trampoline"', | ||
languageOptions: { parser: require(parsers.BABEL) }, | ||
errors: [ | ||
'No default export found in imported module "./broken-trampoline".', | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './broken-trampoline', | ||
}, | ||
}, | ||
], | ||
}), | ||
|
||
// #328: * exports do not include default | ||
test({ | ||
code: 'import barDefault from "./re-export"', | ||
errors: ['No default export found in imported module "./re-export".'], | ||
errors: [ | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './re-export', | ||
}, | ||
}, | ||
], | ||
}), | ||
], | ||
}) | ||
|
@@ -190,7 +231,12 @@ if (!CASE_SENSITIVE_FS) { | |
test({ | ||
code: 'import bar from "./Named-Exports"', | ||
errors: [ | ||
'No default export found in imported module "./Named-Exports".', | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './Named-Exports', | ||
}, | ||
}, | ||
], | ||
}), | ||
], | ||
|
@@ -321,7 +367,14 @@ describe('TypeScript', () => { | |
'import-x/parsers': { [parsers.TS]: ['.ts'] }, | ||
'import-x/resolver': { 'eslint-import-resolver-typescript': true }, | ||
}, | ||
errors: ['No default export found in imported module "./typescript".'], | ||
errors: [ | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './typescript', | ||
}, | ||
}, | ||
], | ||
}), | ||
test({ | ||
code: `import React from "./typescript-export-assign-default-namespace"`, | ||
|
@@ -331,7 +384,12 @@ describe('TypeScript', () => { | |
'import-x/resolver': { 'eslint-import-resolver-typescript': true }, | ||
}, | ||
errors: [ | ||
'No default export found in imported module "./typescript-export-assign-default-namespace".', | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './typescript-export-assign-default-namespace', | ||
}, | ||
}, | ||
], | ||
}), | ||
test({ | ||
|
@@ -342,7 +400,12 @@ describe('TypeScript', () => { | |
'import-x/resolver': { 'eslint-import-resolver-typescript': true }, | ||
}, | ||
errors: [ | ||
'No default export found in imported module "./typescript-export-as-default-namespace".', | ||
{ | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './typescript-export-as-default-namespace', | ||
}, | ||
}, | ||
], | ||
}), | ||
test({ | ||
|
@@ -362,8 +425,10 @@ describe('TypeScript', () => { | |
}, | ||
errors: [ | ||
{ | ||
message: | ||
'No default export found in imported module "./typescript-export-as-default-namespace".', | ||
messageId: 'noDefaultExport', | ||
data: { | ||
module: './typescript-export-as-default-namespace', | ||
}, | ||
line: 1, | ||
column: 8, | ||
endLine: 1, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.