-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
chore: use swc for tests instead of Babel #4584
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7e0fada
chore: use swc for tests instead of Babel
JoshuaKGoldberg 214ad17
chore: lower jsc.target to es2019
JoshuaKGoldberg ea91f08
test: got integration tests running
JoshuaKGoldberg 9437439
Merge branch 'main' into swc
JoshuaKGoldberg 7f86a69
test: add back jest-resolver
JoshuaKGoldberg ff8963f
test: add back another babel types package and reset snapshots
JoshuaKGoldberg f68e0ed
chore: switch syntax to work around SWC bug
JoshuaKGoldberg 6078abe
Merge branch 'main' into swc
JoshuaKGoldberg b2dafa8
Merge branch 'main' into swc
JoshuaKGoldberg 9216077
Merge branch 'main' into swc
JoshuaKGoldberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
// @ts-check | ||
/** @type {import('@jest/types').Config.InitialOptions} */ | ||
module.exports = { | ||
collectCoverage: false, | ||
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'], | ||
coverageReporters: ['text-summary', 'lcov'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
resolver: '<rootDir>/../../tests/jest-resolver.js', | ||
transform: { | ||
'^.+\\.(t|j)sx?$': [ | ||
'@swc/jest', | ||
{ | ||
jsc: { | ||
target: 'es2019', | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,57 +85,54 @@ export default util.createRule({ | |
}), | ||
...(option === 'type' && { | ||
TSInterfaceDeclaration(node): void { | ||
const fix = isCurrentlyTraversedNodeWithinModuleDeclaration() | ||
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. These changes don't do anything other than get us around swc-project/swc#3672 |
||
? null | ||
: (fixer: TSESLint.RuleFixer): TSESLint.RuleFix[] => { | ||
const typeNode = node.typeParameters ?? node.id; | ||
const fixes: TSESLint.RuleFix[] = []; | ||
|
||
const firstToken = sourceCode.getTokenBefore(node.id); | ||
if (firstToken) { | ||
fixes.push(fixer.replaceText(firstToken, 'type')); | ||
fixes.push( | ||
fixer.replaceTextRange( | ||
[typeNode.range[1], node.body.range[0]], | ||
' = ', | ||
), | ||
); | ||
} | ||
|
||
if (node.extends) { | ||
node.extends.forEach(heritage => { | ||
const typeIdentifier = sourceCode.getText(heritage); | ||
fixes.push( | ||
fixer.insertTextAfter(node.body, ` & ${typeIdentifier}`), | ||
); | ||
}); | ||
} | ||
|
||
if ( | ||
node.parent?.type === AST_NODE_TYPES.ExportDefaultDeclaration | ||
) { | ||
fixes.push( | ||
fixer.removeRange([node.parent.range[0], node.range[0]]), | ||
fixer.insertTextAfter( | ||
node.body, | ||
`\nexport default ${node.id.name}`, | ||
), | ||
); | ||
} | ||
|
||
return fixes; | ||
}; | ||
context.report({ | ||
node: node.id, | ||
messageId: 'typeOverInterface', | ||
/** | ||
* remove automatically fix when the interface is within a declare global | ||
* @see {@link https://github.com/typescript-eslint/typescript-eslint/issues/2707} | ||
*/ | ||
fix: isCurrentlyTraversedNodeWithinModuleDeclaration() | ||
? null | ||
: (fixer): TSESLint.RuleFix[] => { | ||
const typeNode = node.typeParameters ?? node.id; | ||
const fixes: TSESLint.RuleFix[] = []; | ||
|
||
const firstToken = sourceCode.getTokenBefore(node.id); | ||
if (firstToken) { | ||
fixes.push(fixer.replaceText(firstToken, 'type')); | ||
fixes.push( | ||
fixer.replaceTextRange( | ||
[typeNode.range[1], node.body.range[0]], | ||
' = ', | ||
), | ||
); | ||
} | ||
|
||
if (node.extends) { | ||
node.extends.forEach(heritage => { | ||
const typeIdentifier = sourceCode.getText(heritage); | ||
fixes.push( | ||
fixer.insertTextAfter( | ||
node.body, | ||
` & ${typeIdentifier}`, | ||
), | ||
); | ||
}); | ||
} | ||
|
||
if ( | ||
node.parent?.type === | ||
AST_NODE_TYPES.ExportDefaultDeclaration | ||
) { | ||
fixes.push( | ||
fixer.removeRange([node.parent.range[0], node.range[0]]), | ||
fixer.insertTextAfter( | ||
node.body, | ||
`\nexport default ${node.id.name}`, | ||
), | ||
); | ||
} | ||
|
||
return fixes; | ||
}, | ||
fix, | ||
}); | ||
}, | ||
}), | ||
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.