Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(eslint-plugin): [interface-name-prefix] correct error message in …
…always mode (#333)

interface-name-prefix currenlty provides 'Interface name must not be
prefixed with "I".' but when in always mode it should give an error
message that matches the intent, added 'Interface name must be prefixed
with "I".' for when "always" is enabled
  • Loading branch information
JProgrammer authored and bradzacher committed Mar 6, 2019
1 parent 00eae48 commit 097262f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/eslint-plugin/src/rules/interface-name-prefix.ts
@@ -1,7 +1,7 @@
import * as util from '../util';

type Options = ['never' | 'always'];
type MessageIds = 'noPrefix';
type MessageIds = 'noPrefix' | 'alwaysPrefix';

export default util.createRule<Options, MessageIds>({
name: 'interface-name-prefix',
Expand All @@ -15,6 +15,7 @@ export default util.createRule<Options, MessageIds>({
},
messages: {
noPrefix: 'Interface name must not be prefixed with "I".',
alwaysPrefix: 'Interface name must be prefixed with "I".',
},
schema: [
{
Expand Down Expand Up @@ -51,7 +52,7 @@ export default util.createRule<Options, MessageIds>({
if (!isPrefixedWithI(node.id.name)) {
context.report({
node: node.id,
messageId: 'noPrefix',
messageId: 'alwaysPrefix',
});
}
}
Expand Down
Expand Up @@ -77,7 +77,7 @@ interface Animal {
options: ['always'],
errors: [
{
messageId: 'noPrefix',
messageId: 'alwaysPrefix',
line: 2,
column: 11,
},
Expand All @@ -92,7 +92,7 @@ interface Iguana {
options: ['always'],
errors: [
{
messageId: 'noPrefix',
messageId: 'alwaysPrefix',
line: 2,
column: 11,
},
Expand Down

0 comments on commit 097262f

Please sign in to comment.