-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f45e5f
commit a2b6676
Showing
7 changed files
with
97 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import type { Rule } from "eslint"; | ||
import type { Node } from "estree"; | ||
import { createSimpleRule, getRuleName } from "../utils.js"; | ||
import { getRuleName } from "../utils.js"; | ||
|
||
export const noConstEnum = createSimpleRule({ | ||
name: getRuleName(import.meta.url), | ||
message: "Disallow using `const enum` expression.", | ||
const name = getRuleName(import.meta.url); | ||
const messages = { | ||
default: "Disallow using `const enum` expression.", | ||
} as const; | ||
const rule: Rule.RuleModule = { | ||
meta: { | ||
messages, | ||
}, | ||
create: (context) => ({ | ||
"TSEnumDeclaration[const=true]": (node: Node) => { | ||
context.reportNode(node); | ||
context.report({ node, messageId: messages.default }); | ||
}, | ||
}), | ||
}); | ||
}; | ||
|
||
export const noConstEnum = { name, rule }; |
This file contains 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
20 changes: 14 additions & 6 deletions
20
packages/eslint-plugin-ts/src/rules/no-export-assignment.ts
This file contains 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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import type { Rule } from "eslint"; | ||
import type { Node } from "estree"; | ||
import { createSimpleRule, getRuleName } from "../utils.js"; | ||
import { getRuleName } from "../utils.js"; | ||
|
||
export const noExportAssignment = createSimpleRule({ | ||
name: getRuleName(import.meta.url), | ||
message: "Disallow using `export =` statement.", | ||
const name = getRuleName(import.meta.url); | ||
const messages = { | ||
default: "Disallow using `export =` statement.", | ||
} as const; | ||
const rule: Rule.RuleModule = { | ||
meta: { | ||
messages, | ||
}, | ||
create: (context) => ({ | ||
TSExportAssignment: (node: Node) => { | ||
context.reportNode(node); | ||
context.report({ node, messageId: messages.default }); | ||
}, | ||
}), | ||
}); | ||
}; | ||
|
||
export const noExportAssignment = { name, rule }; |
This file contains 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
19 changes: 13 additions & 6 deletions
19
packages/eslint-plugin-ts/src/rules/no-untyped-empty-array.ts
This file contains 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 |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import type { Rule } from "eslint"; | ||
import type { Node } from "estree"; | ||
import { createSimpleRule, getRuleName } from "../utils.js"; | ||
import { getRuleName } from "../utils.js"; | ||
|
||
export const noUntypedEmptyArray = createSimpleRule({ | ||
name: getRuleName(import.meta.url), | ||
message: | ||
const name = getRuleName(import.meta.url); | ||
const messages = { | ||
default: | ||
"Defining a variable with an empty array should annotate the array type", | ||
}; | ||
const rule: Rule.RuleModule = { | ||
meta: { | ||
messages, | ||
}, | ||
create: (context) => ({ | ||
"VariableDeclarator:not([id.typeAnnotation]) > ArrayExpression.init[elements.length=0]": | ||
(node: Node) => { | ||
context.reportNode(node); | ||
context.report({ node, messageId: messages.default }); | ||
}, | ||
}), | ||
}); | ||
}; | ||
export const noUntypedEmptyArray = { name, rule }; |
This file contains 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