Skip to content
Permalink
Browse files

Fix: add end location to reports in keyword-spacing (refs #12334) (#1…

  • Loading branch information
mdjermanovic committed Jul 7, 2020
1 parent 2ea7ee5 commit 10251bbaeba80ac15244f385fc42cf2f2a30e5d2
Showing with 62 additions and 22 deletions.
  1. +2 −2 lib/rules/keyword-spacing.js
  2. +60 −20 tests/lib/rules/keyword-spacing.js
@@ -126,7 +126,7 @@ module.exports = {
!sourceCode.isSpaceBetweenTokens(prevToken, token)
) {
context.report({
loc: token.loc.start,
loc: token.loc,
messageId: "expectedBefore",
data: token,
fix(fixer) {
@@ -178,7 +178,7 @@ module.exports = {
!sourceCode.isSpaceBetweenTokens(token, nextToken)
) {
context.report({
loc: token.loc.start,
loc: token.loc,
messageId: "expectedAfter",
data: token,
fix(fixer) {
@@ -1364,14 +1364,14 @@ ruleTester.run("keyword-spacing", rule, {
code: "import *as a from \"foo\"",
output: "import * as a from \"foo\"",
parserOptions: { ecmaVersion: 6, sourceType: "module" },
errors: expectedBefore("as")
},
{
code: "import* as a from\"foo\"",
output: "import*as a from\"foo\"",
options: [NEITHER],
parserOptions: { ecmaVersion: 6, sourceType: "module" },
errors: unexpectedBefore("as")
errors: [{
messageId: "expectedBefore",
data: { value: "as" },
line: 1,
column: 9,
endLine: 1,
endColumn: 11
}]
},
{
code: "import* as a from\"foo\"",
@@ -1380,27 +1380,26 @@ ruleTester.run("keyword-spacing", rule, {
parserOptions: { ecmaVersion: 6, sourceType: "module" },
errors: [{
messageId: "unexpectedBefore",
data: { value: "as" },
line: 1,
column: 8,
endLine: 1,
endColumn: 9
}
]
}]
},
{
code: "import *as a from\"foo\"",
code: "import* as a from\"foo\"",
output: "import*as a from\"foo\"",
options: [NEITHER],
parserOptions: { ecmaVersion: 6, sourceType: "module" },
errors: [
{
messageId: "unexpectedAfter",
line: 1,
column: 7,
endLine: 1,
endColumn: 8
}
]
errors: [{
messageId: "unexpectedBefore",
data: { value: "as" },
line: 1,
column: 8,
endLine: 1,
endColumn: 11
}]
},
{
code: "import*as a from\"foo\"",
@@ -2510,6 +2509,47 @@ ruleTester.run("keyword-spacing", rule, {
// import
//----------------------------------------------------------------------

{
code: "import* as a from \"foo\"",
output: "import * as a from \"foo\"",
parserOptions: { ecmaVersion: 6, sourceType: "module" },
errors: [{
messageId: "expectedAfter",
data: { value: "import" },
line: 1,
column: 1,
endLine: 1,
endColumn: 7
}]
},
{
code: "import *as a from\"foo\"",
output: "import*as a from\"foo\"",
options: [NEITHER],
parserOptions: { ecmaVersion: 6, sourceType: "module" },
errors: [{
messageId: "unexpectedAfter",
data: { value: "import" },
line: 1,
column: 7,
endLine: 1,
endColumn: 8
}]
},
{
code: "import *as a from\"foo\"",
output: "import*as a from\"foo\"",
options: [NEITHER],
parserOptions: { ecmaVersion: 6, sourceType: "module" },
errors: [{
messageId: "unexpectedAfter",
data: { value: "import" },
line: 1,
column: 7,
endLine: 1,
endColumn: 10
}]
},
{
code: "{}import{a} from \"foo\"",
output: "{} import {a} from \"foo\"",

0 comments on commit 10251bb

Please sign in to comment.
You can’t perform that action at this time.