Skip to content
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

[eslint-plugin] update regex of matching TypeScript file extentions #32571

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default createRule({
},
defaultOptions: [],
create(context) {
if (!/\.ts$/.test(context.filename)) {
if (!/\.ts|\.mts|\.cts$/.test(context.filename)) {
return {};
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default createRule({
const fileName = context.filename;

// on the first run, if on a .ts file (program.getSourceFile is file-type dependent)
if (context.settings.exported === undefined && /\.ts$/.test(fileName)) {
if (context.settings.exported === undefined && /\.ts|\.mts|\.cts$/.test(fileName)) {
const packageExports = getLocalExports(context);
if (packageExports !== undefined) {
context.settings.exported = packageExports;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
},
"include": [
"file.ts",
"file-browser.mts",
"package.json",
"not_package.json",
"src/test.ts",
"src/test-browser.mts",
"tests/test.ts",
"service-bus/package.json",
"invalid/package.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ ruleTester.run("github-source-headers", rule, {
code: valid,
filename: "file.ts",
},
{
// only the fields we care about
code: valid,
filename: "file-browser.mts",
},
{
// incorrect format but in a file we don't care about
code: 'console.log("hello")',
Expand All @@ -57,6 +62,17 @@ ruleTester.run("github-source-headers", rule, {
],
output: valid,
},
{
// no comments .mts
code: 'console.log("hello")',
filename: "file-browser.mts",
errors: [
{
message: configError,
},
],
output: valid,
},
// wrong headers
{
code: invalid1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ ruleTester.run("ts-doc-internal", rule, {
function ExampleFunction() {}`,
filename: "src/test.ts",
},
{
code: `
/**
* Other documentation
* @hidden
*/
function ExampleFunction() {}`,
filename: "src/test-browser.mts",
},
],
invalid: [
// class
Expand Down Expand Up @@ -119,5 +128,20 @@ ruleTester.run("ts-doc-internal", rule, {
},
],
},
// .mts file
{
code: `
/**
* Other documentation
* @ignore
*/
function ExampleFunction() {}`,
filename: "src/test-browser.mts",
errors: [
{
message: "internal items with TSDoc comments should include an @internal or @hidden tag",
},
],
},
],
});
Loading