Permalink
Browse files

Update: Don't ignore comments (no-trailing-spaces) (#9416)

  • Loading branch information...
qistoph authored and not-an-aardvark committed Oct 16, 2017
1 parent 5012661 commit ebb530d532c028608a17df857be8aa9cc13bf4ed
Showing with 25 additions and 4 deletions.
  1. +3 −3 lib/rules/generator-star-spacing.js
  2. +1 −1 lib/rules/no-trailing-spaces.js
  3. +21 −0 tests/lib/rules/no-trailing-spaces.js
@@ -68,7 +68,7 @@ module.exports = {
/**
* Returns resolved option definitions based on an option and defaults
*
*
* @param {any} option - The option object or string value
* @param {Object} defaults - The defaults to use if options are not present
* @returns {Object} the resolved object definition
@@ -121,7 +121,7 @@ module.exports = {
/**
* Checks the spacing between two tokens before or after the star token.
*
*
* @param {string} kind Either "named", "anonymous", or "method"
* @param {string} side Either "before" or "after".
* @param {Token} leftToken `function` keyword token if side is "before", or
@@ -161,7 +161,7 @@ module.exports = {
/**
* Enforces the spacing around the star if node is a generator function.
*
*
* @param {ASTNode} node A function expression or declaration node.
* @returns {void}
*/
@@ -49,7 +49,7 @@ module.exports = {
const options = context.options[0] || {},
skipBlankLines = options.skipBlankLines || false,
ignoreComments = typeof options.ignoreComments === "undefined" || options.ignoreComments;
ignoreComments = typeof options.ignoreComments === "boolean" && options.ignoreComments;
/**
* Report the error message
@@ -71,6 +71,14 @@ ruleTester.run("no-trailing-spaces", rule, {
code: "// Trailing comment test. ",
options: [{ ignoreComments: true }]
},
{
code: "// Trailing comment test.",
options: [{ ignoreComments: false }]
},
{
code: "// Trailing comment test.",
options: []
},
{
code: "/* \nTrailing comments test. \n*/",
options: [{ ignoreComments: true }]
@@ -484,6 +492,19 @@ ruleTester.run("no-trailing-spaces", rule, {
column: 20
}
]
},
{
code: "// Trailing comment default test. ",
output: "// Trailing comment default test.",
options: [],
errors: [
{
message: "Trailing spaces not allowed.",
type: "Program",
line: 1,
column: 34
}
]
}
]
});

0 comments on commit ebb530d

Please sign in to comment.