From 72d83d31fa027516830cb6323ac92e46f04ac40f Mon Sep 17 00:00:00 2001 From: Amin Mirzaee Date: Sun, 11 Feb 2018 18:18:18 -0500 Subject: [PATCH] Compatibility for eslint plugin, (mainly adding column numbers in output) --- Cakefile | 6 ++++++ src/ast_linter.coffee | 3 +++ src/commandline.coffee | 2 -- src/lexical_linter.coffee | 11 ++++++++++- src/line_linter.coffee | 2 +- src/rules/arrow_spacing.coffee | 2 +- src/rules/braces_spacing.coffee | 2 +- src/rules/camel_case_classes.coffee | 2 +- src/rules/colon_assignment_spacing.coffee | 1 + src/rules/cyclomatic_complexity.coffee | 2 ++ src/rules/duplicate_key.coffee | 2 +- src/rules/empty_constructor_needs_parens.coffee | 6 +++--- src/rules/ensure_comprehensions.coffee | 4 ++-- src/rules/indentation.coffee | 3 ++- src/rules/line_endings.coffee | 2 +- src/rules/max_line_length.coffee | 1 + src/rules/missing_fat_arrows.coffee | 1 + src/rules/no_backticks.coffee | 3 ++- src/rules/no_debugger.coffee | 4 ++-- src/rules/no_empty_functions.coffee | 1 + src/rules/no_empty_param_list.coffee | 3 ++- src/rules/no_implicit_braces.coffee | 2 +- src/rules/no_implicit_parens.coffee | 4 ++-- src/rules/no_interpolation_in_single_quotes.coffee | 3 ++- src/rules/no_nested_string_interpolation.coffee | 5 +++-- src/rules/no_plusplus.coffee | 2 +- src/rules/no_private_function_fat_arrows.coffee | 1 + src/rules/no_stand_alone_at.coffee | 2 +- src/rules/no_tabs.coffee | 2 +- src/rules/no_this.coffee | 2 +- src/rules/no_throwing_strings.coffee | 3 ++- src/rules/no_trailing_whitespace.coffee | 7 ++++--- src/rules/no_unnecessary_double_quotes.coffee | 3 ++- src/rules/no_unnecessary_fat_arrows.coffee | 1 + src/rules/non_empty_constructor_needs_parens.coffee | 4 ++-- src/rules/prefer_english_operator.coffee | 2 +- src/rules/space_operators.coffee | 4 ++-- src/rules/spacing_after_comma.coffee | 2 +- 38 files changed, 72 insertions(+), 40 deletions(-) diff --git a/Cakefile b/Cakefile index 8e27ce2e..343e32ca 100644 --- a/Cakefile +++ b/Cakefile @@ -24,11 +24,17 @@ task 'compile:commandline', 'Compiles commandline.js', -> coffeeSync 'src/cache.coffee', 'lib/cache.js' coffeeSync 'src/ruleLoader.coffee', 'lib/ruleLoader.js' fs.mkdirSync 'lib/reporters' unless fs.existsSync 'lib/reporters' + fs.mkdirSync 'lib/rules' unless fs.existsSync 'lib/rules' for src in glob.sync('reporters/*.coffee', { cwd: 'src' }) # Slice the "coffee" extension of the end and replace with js dest = src[...-6] + 'js' coffeeSync "src/#{src}", "lib/#{dest}" + for src in glob.sync('rules/*.coffee', { cwd: 'src' }) + # Slice the "coffee" extension of the end and replace with js + dest = src[...-6] + 'js' + coffeeSync "src/#{src}", "lib/#{dest}" + task 'compile:browserify', 'Uses browserify to compile coffeelint', -> opts = standalone: 'coffeelint' diff --git a/src/ast_linter.coffee b/src/ast_linter.coffee index 6afdcafc..26152b2d 100644 --- a/src/ast_linter.coffee +++ b/src/ast_linter.coffee @@ -74,12 +74,15 @@ module.exports = class ASTLinter extends BaseLinter lineNumber = -1 if coffeeError.location? lineNumber = coffeeError.location.first_line + 1 + columnNumber = coffeeError.location.first_column + 1 else match = /line (\d+)/.exec message lineNumber = parseInt match[1], 10 if match?.length > 1 + columnNumber = 1 attrs = { message: message level: rule.level lineNumber: lineNumber + columnNumber: columnNumber } return @createError 'coffeescript_error', attrs diff --git a/src/commandline.coffee b/src/commandline.coffee index 1c2e6508..188a3503 100644 --- a/src/commandline.coffee +++ b/src/commandline.coffee @@ -65,8 +65,6 @@ findCoffeeScripts = (paths, extension) -> # Return an error report from linting the given paths. lintFiles = (files, config) -> - - errorReport = new coffeelint.getErrorReport() for file in files source = read(file) diff --git a/src/lexical_linter.coffee b/src/lexical_linter.coffee index 4986fcab..e6ee9c78 100644 --- a/src/lexical_linter.coffee +++ b/src/lexical_linter.coffee @@ -56,7 +56,7 @@ module.exports = class LexicalLinter extends BaseLinter # error for the same token. errors = [] for rule in @rules when token[0] in rule.tokens - v = @normalizeResult rule, rule.lintToken(token, @tokenApi) + v = @normalizeResult rule, rule.lintToken(token, @tokenApi), token: token errors.push v if v? errors @@ -64,4 +64,13 @@ module.exports = class LexicalLinter extends BaseLinter attrs.lineNumber ?= @lineNumber attrs.lineNumber += 1 attrs.line = @tokenApi.lines[attrs.lineNumber - 1] + if attrs.token + token = attrs.token + attrs.lineNumber = token[2].first_line + 1 + attrs.columnNumber = token[2].first_column + 1 + if token[2].last_line + attrs.lineNumberEnd = token[2].last_line + 1 + if token[2].last_column + attrs.columnNumberEnd = token[2].last_column + 1 + super ruleName, attrs diff --git a/src/line_linter.coffee b/src/line_linter.coffee index bdd4496b..88826306 100644 --- a/src/line_linter.coffee +++ b/src/line_linter.coffee @@ -138,6 +138,6 @@ module.exports = class LineLinter extends BaseLinter createError: (rule, attrs = {}) -> - attrs.lineNumber = @lineNumber + 1 # Lines are indexed by zero. + attrs.lineNumber ?= @lineNumber + 1 # Lines are indexed by zero. attrs.level = @config[rule]?.level super rule, attrs diff --git a/src/rules/arrow_spacing.coffee b/src/rules/arrow_spacing.coffee index 8771553d..4d4963b6 100644 --- a/src/rules/arrow_spacing.coffee +++ b/src/rules/arrow_spacing.coffee @@ -57,6 +57,6 @@ module.exports = class ArrowSpacing pp.generated? or #2 pp[0] is 'INDENT' or #3 (pp[1] is '(' and not pp.generated?)) #4 - true + { token } else null diff --git a/src/rules/braces_spacing.coffee b/src/rules/braces_spacing.coffee index 2e99570e..da10db10 100644 --- a/src/rules/braces_spacing.coffee +++ b/src/rules/braces_spacing.coffee @@ -82,4 +82,4 @@ module.exports = class BracesSpacing msg = "There should be #{expected} space" msg += 's' unless expected is 1 msg += " inside \"#{token[0]}\"" - context: msg + { token, context: msg } diff --git a/src/rules/camel_case_classes.coffee b/src/rules/camel_case_classes.coffee index 679c1826..43baef40 100644 --- a/src/rules/camel_case_classes.coffee +++ b/src/rules/camel_case_classes.coffee @@ -48,4 +48,4 @@ module.exports = class CamelCaseClasses # Now check for the error. if not regexes.camelCase.test(className) - return { context: "class name: #{className}" } + return { token, context: "class name: #{className}" } diff --git a/src/rules/colon_assignment_spacing.coffee b/src/rules/colon_assignment_spacing.coffee index df619a49..e2982d13 100644 --- a/src/rules/colon_assignment_spacing.coffee +++ b/src/rules/colon_assignment_spacing.coffee @@ -63,4 +63,5 @@ module.exports = class ColonAssignmentSpacing if token.csxColon or isLeftSpaced and isRightSpaced null else + token: token context: "Incorrect spacing around column #{token[2].first_column}" diff --git a/src/rules/cyclomatic_complexity.coffee b/src/rules/cyclomatic_complexity.coffee index 5bc2cc6d..4146e59a 100644 --- a/src/rules/cyclomatic_complexity.coffee +++ b/src/rules/cyclomatic_complexity.coffee @@ -47,6 +47,8 @@ module.exports = class CyclomaticComplexity context: complexity + 1 lineNumber: node.locationData.first_line + 1 lineNumberEnd: node.locationData.last_line + 1 + columnNumber: node.locationData.first_column + 1 + columnNumberEnd: node.locationData.last_column + 1 } @errors.push error if error diff --git a/src/rules/duplicate_key.coffee b/src/rules/duplicate_key.coffee index 25136939..b499c495 100644 --- a/src/rules/duplicate_key.coffee +++ b/src/rules/duplicate_key.coffee @@ -47,7 +47,7 @@ module.exports = class DuplicateKey # Added a prefix to not interfere with things like "constructor". key = "identifier-#{key}" if @currentScope[key] - return true + return { token } else @currentScope[key] = token null diff --git a/src/rules/empty_constructor_needs_parens.coffee b/src/rules/empty_constructor_needs_parens.coffee index bcc12bbe..3083ab61 100644 --- a/src/rules/empty_constructor_needs_parens.coffee +++ b/src/rules/empty_constructor_needs_parens.coffee @@ -35,8 +35,8 @@ module.exports = class EmptyConstructorNeedsParens # line with implicit parens, and if your parameters start on the # next line, but is missing if there are no params and no parens. if isIdent and nextToken? - return @handleExpectedCallStart(nextToken) + return @handleExpectedCallStart(nextToken, tokenApi) - handleExpectedCallStart: (isCallStart) -> + handleExpectedCallStart: (isCallStart, tokenApi) -> if isCallStart[0] isnt 'CALL_START' - return true + return { token: tokenApi.peek(isCallStart, 1) } diff --git a/src/rules/ensure_comprehensions.coffee b/src/rules/ensure_comprehensions.coffee index bfea54ea..a9513cb9 100644 --- a/src/rules/ensure_comprehensions.coffee +++ b/src/rules/ensure_comprehensions.coffee @@ -52,7 +52,7 @@ module.exports = class EnsureComprehensions break if prevToken[0] is '=' and numParenEnds is numParenStarts - atEqual = true + atEqual = { token } peeker-- @@ -62,7 +62,7 @@ module.exports = class EnsureComprehensions # amount of CALL_START/CALL_END tokens. An unequal number means the list # comprehension is inside of a function call if atEqual and numCallStarts is numCallEnds - return { context: '' } + return { token, context: '' } findIdents: (tokenApi) -> peeker = 1 diff --git a/src/rules/indentation.coffee b/src/rules/indentation.coffee index 018e7fa4..7065fa10 100644 --- a/src/rules/indentation.coffee +++ b/src/rules/indentation.coffee @@ -62,6 +62,7 @@ module.exports = class Indentation if dotIndent % expected isnt 0 return { + token, context: "Expected #{expected} got #{got}" } @@ -97,7 +98,7 @@ module.exports = class Indentation # Now check the indentation. if not ignoreIndent and not (expected in numIndents) - return { context: "Expected #{expected} got #{numIndents[0]}" } + return { token, context: "Expected #{expected} got #{numIndents[0]}" } # Return true if the current token is inside of an array. inArray: () -> diff --git a/src/rules/line_endings.coffee b/src/rules/line_endings.coffee index bcca6cc0..bdd84b75 100644 --- a/src/rules/line_endings.coffee +++ b/src/rules/line_endings.coffee @@ -23,6 +23,6 @@ module.exports = class LineEndings else throw new Error("unknown line ending type: #{ending}") if not valid - return { context: "Expected #{ending}" } + return { columnNumber: line.length, context: "Expected #{ending}" } else return null diff --git a/src/rules/max_line_length.coffee b/src/rules/max_line_length.coffee index 3856ddb4..8913ec60 100644 --- a/src/rules/max_line_length.coffee +++ b/src/rules/max_line_length.coffee @@ -41,5 +41,6 @@ module.exports = class MaxLineLength return return { + columnNumber: max context: "Length is #{lineLength}, max is #{max}" } diff --git a/src/rules/missing_fat_arrows.coffee b/src/rules/missing_fat_arrows.coffee index d6c30936..76f24744 100644 --- a/src/rules/missing_fat_arrows.coffee +++ b/src/rules/missing_fat_arrows.coffee @@ -49,6 +49,7 @@ module.exports = class MissingFatArrows (@needsFatArrow node) error = @astApi.createError lineNumber: node.locationData.first_line + 1 + columnNumber: node.locationData.first_column + 1 @errors.push error node.eachChild (child) => @lintNode child, diff --git a/src/rules/no_backticks.coffee b/src/rules/no_backticks.coffee index 02420d9e..cc71faf6 100644 --- a/src/rules/no_backticks.coffee +++ b/src/rules/no_backticks.coffee @@ -16,4 +16,5 @@ module.exports = class NoBackticks tokens: ['JS'] lintToken: (token, tokenApi) -> - return not token.comments? + if not token.comments? + { token } diff --git a/src/rules/no_debugger.coffee b/src/rules/no_debugger.coffee index a5ed3c93..41bfa9cc 100644 --- a/src/rules/no_debugger.coffee +++ b/src/rules/no_debugger.coffee @@ -15,9 +15,9 @@ module.exports = class NoDebugger lintToken: (token, tokenApi) -> if token[0] in ['DEBUGGER', 'STATEMENT'] and token[1] is 'debugger' - return { context: "found '#{token[0]}'" } + return { token, context: "found '#{token[0]}'" } if tokenApi.config[@rule.name]?.console if token[1] is 'console' and tokenApi.peek(1)?[0] is '.' method = tokenApi.peek(2) - return { context: "found 'console.#{method[1]}'" } + return { token, context: "found 'console.#{method[1]}'" } diff --git a/src/rules/no_empty_functions.coffee b/src/rules/no_empty_functions.coffee index bd06ac27..88525400 100644 --- a/src/rules/no_empty_functions.coffee +++ b/src/rules/no_empty_functions.coffee @@ -41,5 +41,6 @@ module.exports = class NoEmptyFunctions if isEmptyCode node, astApi error = astApi.createError lineNumber: node.locationData.first_line + 1 + columnNumber: node.locationData.first_column + 1 @errors.push error node.eachChild (child) => @lintNode child, astApi diff --git a/src/rules/no_empty_param_list.coffee b/src/rules/no_empty_param_list.coffee index b8baebe8..a98c7629 100644 --- a/src/rules/no_empty_param_list.coffee +++ b/src/rules/no_empty_param_list.coffee @@ -21,4 +21,5 @@ module.exports = class NoEmptyParamList lintToken: (token, tokenApi) -> nextType = tokenApi.peek()[0] - return nextType is 'PARAM_END' + if nextType is 'PARAM_END' + return { token } diff --git a/src/rules/no_implicit_braces.coffee b/src/rules/no_implicit_braces.coffee index 56833bf5..522aa484 100644 --- a/src/rules/no_implicit_braces.coffee +++ b/src/rules/no_implicit_braces.coffee @@ -83,7 +83,7 @@ module.exports = class NoImplicitBraces if peekIdent is @className return - return true + return { token: tokenApi.peek(c + 1) } trackClass: (token, tokenApi) -> diff --git a/src/rules/no_implicit_parens.coffee b/src/rules/no_implicit_parens.coffee index aa281fe6..e96ee32b 100644 --- a/src/rules/no_implicit_parens.coffee +++ b/src/rules/no_implicit_parens.coffee @@ -25,7 +25,7 @@ module.exports = class NoImplicitParens lintToken: (token, tokenApi) -> if token.generated unless tokenApi.config[@rule.name].strict is false - return true + return { token } else # If strict mode is turned off it allows implicit parens when # the expression is spread over multiple lines. @@ -36,7 +36,7 @@ module.exports = class NoImplicitParens genCallStart = t[0] is 'CALL_START' and t.generated if not t? or genCallStart and sameLine - return true + return { token: t or token } # If we have not found a CALL_START token that is generated, # and we've moved into a new line, this is fine and should diff --git a/src/rules/no_interpolation_in_single_quotes.coffee b/src/rules/no_interpolation_in_single_quotes.coffee index aa7bdd4a..c38c9949 100644 --- a/src/rules/no_interpolation_in_single_quotes.coffee +++ b/src/rules/no_interpolation_in_single_quotes.coffee @@ -23,4 +23,5 @@ module.exports = class NoInterpolationInSingleQuotes lintToken: (token, tokenApi) -> tokenValue = token[1] hasInterpolation = tokenValue.match(/^\'.*#\{[^}]+\}.*\'$/) - return hasInterpolation + if hasInterpolation + return { token } diff --git a/src/rules/no_nested_string_interpolation.coffee b/src/rules/no_nested_string_interpolation.coffee index b5f58ac1..30e51d67 100644 --- a/src/rules/no_nested_string_interpolation.coffee +++ b/src/rules/no_nested_string_interpolation.coffee @@ -22,7 +22,8 @@ module.exports = class NoNestedStringInterpolation constructor: -> @blocks = [] - lintToken: ([tag], tokenApi) -> + lintToken: (token, tokenApi) -> + [tag] = token @blocks.push [] unless @blocks.length block = @blocks[@blocks.length - 1] @@ -49,5 +50,5 @@ module.exports = class NoNestedStringInterpolation # Don't make multiple errors for deeply nested interpolation if block.strCount > 1 and not block.error block.error = true - return true + return { token } return diff --git a/src/rules/no_plusplus.coffee b/src/rules/no_plusplus.coffee index 5f27893a..8f6a3c0c 100644 --- a/src/rules/no_plusplus.coffee +++ b/src/rules/no_plusplus.coffee @@ -15,4 +15,4 @@ module.exports = class NoPlusPlus tokens: ['++', '--'] lintToken: (token, tokenApi) -> - return { context: "found '#{token[0]}'" } + return { token, context: "found '#{token[0]}'" } diff --git a/src/rules/no_private_function_fat_arrows.coffee b/src/rules/no_private_function_fat_arrows.coffee index 025e4b27..2b8f0154 100644 --- a/src/rules/no_private_function_fat_arrows.coffee +++ b/src/rules/no_private_function_fat_arrows.coffee @@ -18,6 +18,7 @@ module.exports = class NoPrivateFunctionFatArrows if @isFatArrowCode(node) and node in functions error = @astApi.createError lineNumber: node.locationData.first_line + 1 + columnNumber: node.locationData.first_column + 1 @errors.push error node.eachChild (child) => @lintNode child, diff --git a/src/rules/no_stand_alone_at.coffee b/src/rules/no_stand_alone_at.coffee index aa467a18..388f856a 100644 --- a/src/rules/no_stand_alone_at.coffee +++ b/src/rules/no_stand_alone_at.coffee @@ -36,4 +36,4 @@ module.exports = class NoStandAloneAt # is an property, the start of an index '[' or is an property after # the '::' unless (isDot or (noSpace and (isProp or isAStart or isProtoProp))) - return true + return { token } diff --git a/src/rules/no_tabs.coffee b/src/rules/no_tabs.coffee index b2f2fcde..d4417712 100644 --- a/src/rules/no_tabs.coffee +++ b/src/rules/no_tabs.coffee @@ -18,6 +18,6 @@ module.exports = class NoTabs # is the start of the expression. indentation = line.split(indentationRegex)[0] if lineApi.lineHasToken() and '\t' in indentation - true + { columnNumber: indentation.indexOf('\t') } else null diff --git a/src/rules/no_this.coffee b/src/rules/no_this.coffee index b0aa836f..d506b00a 100644 --- a/src/rules/no_this.coffee +++ b/src/rules/no_this.coffee @@ -15,4 +15,4 @@ module.exports = class NoThis { config: { no_stand_alone_at: { level } } } = tokenApi nextToken = tokenApi.peek(1)?[0] - true unless level isnt 'ignore' and nextToken isnt '.' + { token } unless level isnt 'ignore' and nextToken isnt '.' diff --git a/src/rules/no_throwing_strings.coffee b/src/rules/no_throwing_strings.coffee index a866a813..9673da61 100644 --- a/src/rules/no_throwing_strings.coffee +++ b/src/rules/no_throwing_strings.coffee @@ -33,4 +33,5 @@ module.exports = class NoThrowingStrings nextIsString = n1 is 'STRING' or n1 is 'STRING_START' - return nextIsString + if nextIsString + { token } diff --git a/src/rules/no_trailing_whitespace.coffee b/src/rules/no_trailing_whitespace.coffee index 2b89aa65..699c54eb 100644 --- a/src/rules/no_trailing_whitespace.coffee +++ b/src/rules/no_trailing_whitespace.coffee @@ -1,6 +1,7 @@ regexes = trailingWhitespace: /[^\s]+[\t ]+\r?$/ onlySpaces: /^[\t ]+\r?$/ + spacesStart: /[\t ]+\r?$/ lineHasComment: /^\s*[^\#]*\#/ module.exports = class NoTrailingWhitespace @@ -19,12 +20,12 @@ module.exports = class NoTrailingWhitespace lintLine: (line, lineApi) -> unless lineApi.config['no_trailing_whitespace']?.allowed_in_empty_lines if regexes.onlySpaces.test(line) - return true + return { columnNumber: line.match(regexes.spacesStart).length + 1 } if regexes.trailingWhitespace.test(line) # By default only the regex above is needed. unless lineApi.config['no_trailing_whitespace']?.allowed_in_comments - return true + return { columnNumber: line.match(regexes.spacesStart).index + 1 } line = line tokens = lineApi.tokensByLine[lineApi.lineNumber] @@ -40,4 +41,4 @@ module.exports = class NoTrailingWhitespace line = line.replace(str, 'STRING') if !regexes.lineHasComment.test(line) - return true + return { columnNumber: line.match(regexes.spacesStart).index + 1 } diff --git a/src/rules/no_unnecessary_double_quotes.coffee b/src/rules/no_unnecessary_double_quotes.coffee index 9f1c5405..0423eab8 100644 --- a/src/rules/no_unnecessary_double_quotes.coffee +++ b/src/rules/no_unnecessary_double_quotes.coffee @@ -43,7 +43,8 @@ module.exports = class NoUnnecessaryDoubleQuotes return false hasLegalConstructs = @isInInterpolation() or @hasSingleQuote(tokenValue) - return not hasLegalConstructs + if not hasLegalConstructs + { token } isInInterpolation: () -> @interpolationLevel > 0 diff --git a/src/rules/no_unnecessary_fat_arrows.coffee b/src/rules/no_unnecessary_fat_arrows.coffee index d985ba2f..b7b8c746 100644 --- a/src/rules/no_unnecessary_fat_arrows.coffee +++ b/src/rules/no_unnecessary_fat_arrows.coffee @@ -19,6 +19,7 @@ module.exports = class NoUnnecessaryFatArrows if (@isFatArrowCode node) and (not @needsFatArrow node) error = @astApi.createError lineNumber: node.locationData.first_line + 1 + columnNumber: node.locationData.first_column + 1 @errors.push error node.eachChild (child) => @lintNode child diff --git a/src/rules/non_empty_constructor_needs_parens.coffee b/src/rules/non_empty_constructor_needs_parens.coffee index 15337da4..cddd8a89 100644 --- a/src/rules/non_empty_constructor_needs_parens.coffee +++ b/src/rules/non_empty_constructor_needs_parens.coffee @@ -10,6 +10,6 @@ module.exports = class NonEmptyConstructorNeedsParens extends ParentClass Requires constructors with parameters to include the parens ''' - handleExpectedCallStart: (isCallStart) -> + handleExpectedCallStart: (isCallStart, tokenApi) -> if isCallStart[0] is 'CALL_START' and isCallStart.generated - return true + return { token: tokenApi.peek(isCallStart, 1) } diff --git a/src/rules/prefer_english_operator.coffee b/src/rules/prefer_english_operator.coffee index 9dcbd1e6..0ce36671 100644 --- a/src/rules/prefer_english_operator.coffee +++ b/src/rules/prefer_english_operator.coffee @@ -43,4 +43,4 @@ module.exports = class PreferEnglishOperator else undefined if context? - { level, context } + { token, level, context } diff --git a/src/rules/space_operators.coffee b/src/rules/space_operators.coffee index 8fd4b212..5f2d7c6c 100644 --- a/src/rules/space_operators.coffee +++ b/src/rules/space_operators.coffee @@ -52,14 +52,14 @@ module.exports = class SpaceOperators if notFirstToken and ((isUnary and token.spaced?) or (not isUnary and not token.newLine and (not token.spaced or (p and not p.spaced)))) - return { context: token[1] } + return { token, context: token[1] } else null lintMath: (token, tokenApi) -> p = tokenApi.peek(-1) if not token.newLine and (not token.spaced or (p and not p.spaced)) - return { context: token[1] } + return { token, context: token[1] } else null diff --git a/src/rules/spacing_after_comma.coffee b/src/rules/spacing_after_comma.coffee index ddc5725a..6b0a74bf 100644 --- a/src/rules/spacing_after_comma.coffee +++ b/src/rules/spacing_after_comma.coffee @@ -24,7 +24,7 @@ module.exports = class SpacingAfterComma unless token.spaced or token.newLine or @isGenerated(token, tokenApi) or @isRegexFlag(token, tokenApi) - return true + return { token } # Coffeescript does some code generation when using CSX syntax, and it adds # brackets & commas that are not marked as generated. The only way to check