Skip to content

Commit 64b3365

Browse files
armano2JamesHenry
authored andcommitted
[CHORE] Add eslint-plugin-eslint-plugin (typescript-eslint#209)
1 parent ea801a6 commit 64b3365

10 files changed

+56
-30
lines changed

packages/eslint-plugin-typescript/.eslintrc

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"root": true,
33
"plugins": [
44
"node",
5-
"prettier"
5+
"prettier",
6+
"eslint-plugin"
67
],
78
"extends": [
89
"eslint",
910
"plugin:node/recommended",
10-
"prettier"
11+
"prettier",
12+
"plugin:eslint-plugin/recommended"
1113
],
1214
"rules": {
1315
"prettier/prettier": [
@@ -16,6 +18,9 @@
1618
"tabWidth": 4
1719
}
1820
],
19-
"lines-around-comment": "off"
21+
"lines-around-comment": "off",
22+
"eslint-plugin/prefer-placeholders": "error",
23+
"eslint-plugin/prefer-replace-text": "error",
24+
"eslint-plugin/no-deprecated-report-api": "error"
2025
}
2126
}

packages/eslint-plugin-typescript/lib/rules/adjacent-overload-signatures.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = {
2727
/**
2828
* Gets the name of the member being processed.
2929
* @param {ASTNode} member the member being processed.
30-
* @returns {string} the name of the member or null if it's a member not relevant to the rule.
30+
* @returns {string|null} the name of the member or null if it's a member not relevant to the rule.
3131
* @private
3232
*/
3333
function getMemberName(member) {
@@ -92,7 +92,11 @@ module.exports = {
9292
if (index > -1 && lastName !== name) {
9393
context.report({
9494
node: member,
95-
message: `All '${name}' signatures should be adjacent`,
95+
message:
96+
"All '{{name}}' signatures should be adjacent",
97+
data: {
98+
name,
99+
},
96100
});
97101
} else if (name && index === -1) {
98102
seen.push(name);

packages/eslint-plugin-typescript/lib/rules/class-name-casing.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ module.exports = {
6767

6868
context.report({
6969
node: resolvedId,
70-
message: `${friendlyName} '${
71-
resolvedId.name
72-
}' must be PascalCased`,
70+
message: "{{friendlyName}} '{{name}}' must be PascalCased",
71+
data: {
72+
friendlyName,
73+
name: resolvedId.name,
74+
},
7375
});
7476
}
7577

packages/eslint-plugin-typescript/lib/rules/explicit-member-accessibility.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ module.exports = {
4141
) {
4242
context.report({
4343
node: methodDefinition,
44-
message: `Missing accessibility modifier on method definition ${
45-
methodDefinition.key.name
46-
}.`,
44+
message:
45+
"Missing accessibility modifier on method definition {{name}}.",
46+
data: {
47+
name: methodDefinition.key.name,
48+
},
4749
});
4850
}
4951
}
@@ -61,9 +63,11 @@ module.exports = {
6163
) {
6264
context.report({
6365
node: classProperty,
64-
message: `Missing accessibility modifier on class property ${
65-
classProperty.key.name
66-
}.`,
66+
message:
67+
"Missing accessibility modifier on class property {{name}}.",
68+
data: {
69+
name: classProperty.key.name,
70+
},
6771
});
6872
}
6973
}

packages/eslint-plugin-typescript/lib/rules/no-inferrable-types.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ module.exports = {
122122

123123
context.report({
124124
node,
125-
message: `Type ${type} trivially inferred from a ${type} literal, remove type annotation`,
125+
message:
126+
"Type {{type}} trivially inferred from a {{type}} literal, remove type annotation",
127+
data: {
128+
type,
129+
},
126130
fix: fixer => fixer.remove(typeNode),
127131
});
128132
}

packages/eslint-plugin-typescript/lib/rules/type-annotation-spacing.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,21 @@ module.exports = {
117117
if (after && nextDelta === 0) {
118118
context.report({
119119
node: punctuatorTokenEnd,
120-
message: `Expected a space after the '${type}'`,
120+
message: "Expected a space after the '{{type}}'",
121+
data: {
122+
type,
123+
},
121124
fix(fixer) {
122125
return fixer.insertTextAfter(punctuatorTokenEnd, " ");
123126
},
124127
});
125128
} else if (!after && nextDelta > 0) {
126129
context.report({
127130
node: punctuatorTokenEnd,
128-
message: `Unexpected space after the '${type}'`,
131+
message: "Unexpected space after the '{{type}}'",
132+
data: {
133+
type,
134+
},
129135
fix(fixer) {
130136
return fixer.removeRange([
131137
punctuatorTokenEnd.range[1],
@@ -138,15 +144,21 @@ module.exports = {
138144
if (before && previousDelta === 0) {
139145
context.report({
140146
node: punctuatorTokenStart,
141-
message: `Expected a space before the '${type}'`,
147+
message: "Expected a space before the '{{type}}'",
148+
data: {
149+
type,
150+
},
142151
fix(fixer) {
143152
return fixer.insertTextAfter(previousToken, " ");
144153
},
145154
});
146155
} else if (!before && previousDelta > 0) {
147156
context.report({
148157
node: punctuatorTokenStart,
149-
message: `Unexpected space before the '${type}'`,
158+
message: "Unexpected space before the '{{type}}'",
159+
data: {
160+
type,
161+
},
150162
fix(fixer) {
151163
return fixer.removeRange([
152164
previousToken.range[1],

packages/eslint-plugin-typescript/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"eslint-config-eslint": "^5.0.1",
3030
"eslint-config-prettier": "^3.3.0",
3131
"eslint-docs": "^0.1.1",
32+
"eslint-plugin-eslint-plugin": "^2.0.0",
3233
"eslint-plugin-node": "^6.0.1",
3334
"eslint-plugin-prettier": "^3.0.0",
3435
"husky": "^1.2.0",

packages/eslint-plugin-typescript/tests/lib/rules/no-angle-bracket-type-assertion.js

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const foo = {} as Foo<int>;
3333
const bar = new Generic<int>() as Foo;
3434
`,
3535
"const array : Array<string> = [];",
36-
"const array : Array<string> = [];",
3736
`
3837
class A {}
3938
class B extends A {}

packages/eslint-plugin-typescript/tests/lib/rules/type-annotation-spacing.js

-10
Original file line numberDiff line numberDiff line change
@@ -1041,11 +1041,6 @@ type Bar = Record<keyof Foo, string>
10411041
parser: "typescript-eslint-parser",
10421042
},
10431043
"let resolver: (() => PromiseLike<T>) | PromiseLike<T>;",
1044-
`
1045-
interface resolve {
1046-
resolver: (() => PromiseLike<T>) | PromiseLike<T>;
1047-
}
1048-
`,
10491044
],
10501045
invalid: [
10511046
{
@@ -4234,11 +4229,6 @@ type Bar = Record<keyof Foo, string>
42344229
],
42354230
parser: "typescript-eslint-parser",
42364231
},
4237-
`
4238-
interface resolve {
4239-
resolver?: (() => PromiseLike<T>) | PromiseLike<T>;
4240-
}
4241-
`,
42424232
],
42434233
invalid: [
42444234
{

packages/eslint-plugin-typescript/yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,11 @@ eslint-docs@^0.1.1:
708708
read-pkg-up "^2.0.0"
709709
regenerator-runtime "^0.11.0"
710710

711+
eslint-plugin-eslint-plugin@^2.0.0:
712+
version "2.0.0"
713+
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-2.0.0.tgz#9825af354c8fcefda7c99c951243d70687dd9a1d"
714+
integrity sha512-NLJ+Rw23xykBV12hQ/e4Kz8jbmtWSx++Q5dizfM8SjNQyUu/+AU4NUP4hih6iFMByKllTLR/hmVV8xwLpRBCPA==
715+
711716
eslint-plugin-node@^6.0.1:
712717
version "6.0.1"
713718
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz#bf19642298064379315d7a4b2a75937376fa05e4"

0 commit comments

Comments
 (0)