Skip to content

SourceCode not optimize for RuleTester changes #13293

@SuperOleg39

Description

@SuperOleg39

Tell us about your environment

  • ESLint Version: 7

What parser (default, Babel-ESLint, etc.) are you using?

  1. babel-eslint
  2. @typescript-eslint/parser

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

We using RuleTester for custom rule, and have this code inside rule:

// context: Rule.RuleContext
const sourceCode = context.getSourceCode();
const comments = sourceCode.getComments(nodeSource).leading;

After updating to Eslint 7, have a error, because source-code.js use deprecated by rule-tester.js node properties.

What did you expect to happen?

My tests passes succesfull

What actually happened? Please include the actual, raw output from ESLint.

Use token.range[0] instead of token.start
    Occurred while linting <input>:3

      68 |       const chunkName = last(propName.split('/'));
      69 |       const sourceCode = context.getSourceCode();
    > 70 |       const comments = sourceCode.getComments(nodeSource).leading;
         |                                   ^
      71 | 
      72 |       if (!comments || comments.length === 0) {
      73 |         return context.report({

      at Object.get (node_modules/eslint/lib/rule-tester/rule-tester.js:223:23)
      at SourceCode.getComments (node_modules/eslint/lib/source-code/source-code.js:352:50)
      at checkImport (packages/eslint/src/config/rules/bundle-chunk-name.ts:70:35)
      at ImportExpression (packages/eslint/src/config/rules/bundle-chunk-name.ts:134:16)
      at listeners.(anonymous function).forEach.listener (node_modules/eslint/lib/linter/safe-emitter.js:45:58)
          at Array.forEach (<anonymous>)
      at Object.emit (node_modules/eslint/lib/linter/safe-emitter.js:45:38)
      at NodeEventGenerator.applySelector (node_modules/eslint/lib/linter/node-event-generator.js:254:26)
      at NodeEventGenerator.applySelectors (node_modules/eslint/lib/linter/node-event-generator.js:283:22)
      at NodeEventGenerator.enterNode (node_modules/eslint/lib/linter/node-event-generator.js:297:14)

Are you willing to submit a pull request to fix this bug?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    archived due to ageThis issue has been archived; please open a new issue for any further discussionworks as intendedThe behavior described in this issue is working correctly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions