-
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 b82d9ee
Showing
7 changed files
with
93 additions
and
83 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,19 @@ | ||
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 rule: Rule.RuleModule = { | ||
meta: { | ||
messages: { | ||
default: "Disallow using `const enum` expression.", | ||
}, | ||
}, | ||
create: (context) => ({ | ||
"TSEnumDeclaration[const=true]": (node: Node) => { | ||
context.reportNode(node); | ||
context.report({ node, messageId: "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
19 changes: 13 additions & 6 deletions
19
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,19 @@ | ||
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 rule: Rule.RuleModule = { | ||
meta: { | ||
messages: { | ||
default: "Disallow using `export =` statement.", | ||
}, | ||
}, | ||
create: (context) => ({ | ||
TSExportAssignment: (node: Node) => { | ||
context.reportNode(node); | ||
context.report({ node, messageId: "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
20 changes: 13 additions & 7 deletions
20
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,20 @@ | ||
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: | ||
"Defining a variable with an empty array should annotate the array type", | ||
const name = getRuleName(import.meta.url); | ||
const rule: Rule.RuleModule = { | ||
meta: { | ||
messages: { | ||
default: | ||
"Defining a variable with an empty array should annotate the array type", | ||
}, | ||
}, | ||
create: (context) => ({ | ||
"VariableDeclarator:not([id.typeAnnotation]) > ArrayExpression.init[elements.length=0]": | ||
(node: Node) => { | ||
context.reportNode(node); | ||
context.report({ node, messageId: "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