question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Source code fixer doesn't remove sequential ranges

See original GitHub issue

Tell us about your environment

  • ESLint Version: 5.1.0
  • Node Version: 10.6.0
  • npm Version: 6.1.0

What parser (default, Babel-ESLint, etc.) are you using? default Please show your full configuration: I cloned eslint repo.

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

I’m developing fixer for no-unused-var rule. Fixer should remove unused method parameters. Fixer removes one parameter (sometimes with comma) per error. Error is reported for each unused argument. SourceCodeFixer should successfully remove sequential ranges, but SourceCodeFixer recognizes them as overlaps.

I wrote test for SourceCodeFixer:

            const REMOVE_A = {
                message: "removea",
                fix: {
                    range: [11, 12],
                    text: ""
                }
            };

            const REMOVE_B = {
                message: "removeb",
                fix: {
                    range: [12, 15],
                    text: ""
                }
            };

            const REMOVE_C = {
                message: "removec",
                fix: {
                    range: [15, 18],
                    text: ""
                }
            };

            it("should remove text consistently", () => {
                const result = SourceCodeFixer.applyFixes('function f(a, b, c) {}', [REMOVE_A, REMOVE_B, REMOVE_C]);

                assert.strictEqual(result.output, "function f() {}");
                assert.isTrue(result.fixed);
            });

What did you expect to happen? Test should be successful. Output should be "function f() {}".

What actually happened? Please include the actual, raw output from ESLint. Test is failed. Output is "function f(, b) {}".

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Jul 15, 2018

I’m not sure this is a big problem because ESLint runs rules multiple times when autofixing, so the variable b will simply be removed on the next pass when the rule gets run again.

It’s true that it would be safe to apply all the fixes in this case, but I’m not sure it’s safe to apply all the fixes in all other cases. I would rather be conservative here.

0reactions
mysticateacommented, Oct 20, 2018

Yes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation Error Explanations for Genomes - NCBI - NIH
Suggestion: Remove Ns from the beginning and end of the sequence or indicate that the sequence circular, if that is applicable.
Read more >
How to stop excel from changing a range when you ... - YouTube
In this video, we will cover 2 examples of how to keep a range fixed while other range in the formulas can change....
Read more >
dbt-labs/dbt-utils: Utility functions for dbt projects. - GitHub
sequential_values (source). This test confirms that a column contains sequential values. It can be used for both numeric values, and datetime values, as...
Read more >
Sequence contains no elements? - Stack Overflow
The query is fine when retrieving the row to put data in to the text boxes, but it returns an error "Sequence contains...
Read more >
SEQUENCE function in Excel - auto generate number series
See how to use the Excel SEQUENCE function to create a number series starting at a specific value.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found