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

fix(eslint-plugin): handle missing message IDs in eslint v5/v6 #2461

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/eslint-plugin/src/rules/brace-style.ts
Expand Up @@ -20,7 +20,19 @@ export default createRule<Options, MessageIds>({
recommended: false,
extendsBaseRule: true,
},
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
nextLineOpen:
'Opening curly brace does not appear on the same line as controlling statement.',
sameLineOpen:
'Opening curly brace appears on the same line as controlling statement.',
blockSameLine: 'Statement inside of curly braces should be on next line.',
nextLineClose:
'Closing curly brace does not appear on the same line as the subsequent block.',
singleLineClose:
'Closing curly brace should be on the same line as opening curly brace or on the line after the previous block.',
sameLineClose:
'Closing curly brace appears on the same line as the subsequent block.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
fixable: baseRule.meta.fixable,
schema: baseRule.meta.schema,
},
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/dot-notation.ts
Expand Up @@ -43,7 +43,10 @@ export default createRule<Options, MessageIds>({
},
],
fixable: baseRule.meta.fixable,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
useDot: '[{{key}}] is better written in dot notation.',
useBrackets: '.{{key}} is a syntax error.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [
{
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/indent.ts
Expand Up @@ -97,7 +97,10 @@ export default util.createRule<Options, MessageIds>({
},
fixable: 'whitespace',
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
wrongIndentation:
'Expected indentation of {{expected}} but found {{actual}}.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [
// typescript docs and playground use 4 space indent
Expand Down
7 changes: 6 additions & 1 deletion packages/eslint-plugin/src/rules/init-declarations.ts
Expand Up @@ -24,7 +24,12 @@ export default createRule<Options, MessageIds>({
extendsBaseRule: true,
},
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
initialized:
"Variable '{{idName}}' should be initialized on declaration.",
notInitialized:
"Variable '{{idName}}' should not be initialized on declaration.",
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: ['always'],
create(context) {
Expand Down
7 changes: 6 additions & 1 deletion packages/eslint-plugin/src/rules/keyword-spacing.ts
Expand Up @@ -17,7 +17,12 @@ export default util.createRule<Options, MessageIds>({
},
fixable: 'whitespace',
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
expectedBefore: 'Expected space(s) before "{{value}}".',
expectedAfter: 'Expected space(s) after "{{value}}".',
unexpectedBefore: 'Unexpected space(s) before "{{value}}".',
unexpectedAfter: 'Unexpected space(s) after "{{value}}".',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [{}],

Expand Down
Expand Up @@ -32,7 +32,10 @@ export default util.createRule<Options, MessageIds>({
},
fixable: 'whitespace',
schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
never: 'Unexpected blank line between class members.',
always: 'Expected blank line between class members.',
},
bradzacher marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [
'always',
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/no-dupe-class-members.ts
Expand Up @@ -16,7 +16,9 @@ export default util.createRule<Options, MessageIds>({
extendsBaseRule: true,
},
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
unexpected: "Duplicate name '{{name}}'.",
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [],
create(context) {
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/no-empty-function.ts
Expand Up @@ -48,7 +48,9 @@ export default util.createRule<Options, MessageIds>({
extendsBaseRule: true,
},
schema: [schema],
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
unexpected: 'Unexpected empty {{name}}.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [
{
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/no-extra-parens.ts
Expand Up @@ -24,7 +24,9 @@ export default util.createRule<Options, MessageIds>({
},
fixable: 'code',
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
unexpected: 'Unnecessary parentheses around expression.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: ['all'],
create(context) {
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/no-extra-semi.ts
Expand Up @@ -16,7 +16,9 @@ export default util.createRule<Options, MessageIds>({
},
fixable: 'code',
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
unexpected: 'Unnecessary semicolon.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [],
create(context) {
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/no-invalid-this.ts
Expand Up @@ -23,7 +23,9 @@ export default createRule<Options, MessageIds>({
recommended: false,
extendsBaseRule: true,
},
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
unexpectedThis: "Unexpected 'this'.",
},
bradzacher marked this conversation as resolved.
Show resolved Hide resolved
schema: baseRule.meta.schema,
},
defaultOptions: [{ capIsConstructor: true }],
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-magic-numbers.ts
Expand Up @@ -40,7 +40,10 @@ export default util.createRule<Options, MessageIds>({
},
},
],
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
useConst: "Number constants declarations must use 'const'.",
noMagic: 'No magic number: {{raw}}.',
},
bradzacher marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [
{
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/no-unused-expressions.ts
Expand Up @@ -19,7 +19,10 @@ export default util.createRule<Options, MessageIds>({
extendsBaseRule: true,
},
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
unusedExpression:
'Expected an assignment or function call and instead saw an expression.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [
{
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/no-unused-vars.ts
Expand Up @@ -21,7 +21,9 @@ export default util.createRule<Options, MessageIds>({
extendsBaseRule: true,
},
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
unusedVar: "'{{varName}}' is {{action}} but never used{{additional}}.",
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [{}],
create(context) {
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/no-useless-constructor.ts
Expand Up @@ -54,7 +54,9 @@ export default util.createRule<Options, MessageIds>({
extendsBaseRule: true,
},
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
noUselessConstructor: 'Useless constructor.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [],
create(context) {
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-plugin/src/rules/quotes.ts
Expand Up @@ -20,7 +20,9 @@ export default util.createRule<Options, MessageIds>({
extendsBaseRule: true,
},
fixable: 'code',
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
wrongQuotes: 'Strings must use {{description}}.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
schema: baseRule.meta.schema,
},
defaultOptions: [
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin/src/rules/semi.ts
Expand Up @@ -22,7 +22,10 @@ export default util.createRule<Options, MessageIds>({
},
fixable: 'code',
schema: baseRule.meta.schema,
messages: baseRule.meta.messages,
messages: baseRule.meta.messages ?? {
missingSemi: 'Missing semicolon.',
extraSemi: 'Extra semicolon.',
},
esetnik marked this conversation as resolved.
Show resolved Hide resolved
},
defaultOptions: [
'always',
Expand Down