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.

Indentation warnings when the indentation is correct?

See original GitHub issue

Tell us about your environment

  • ESLint Version: 1.0.6
  • Node Version: Unknown. Perhaps installed with VS Code?
  • npm Version: Unknown. Perhaps installed with VS Code?

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

Please show your full configuration: Assuming you mean the .eslintrc.* files, here they are. (Seems indenting isn’t working here):

.eslintrc.js:

module.exports = {
    "env": {
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "rules": {
        "indent": [
            "error",
            "tab"
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "double"
        ],
        "semi": [
            "error",
            "always"
        ]
    }
};

.eslintrc.json:

{
    "env": {
        "browser": true,
        "commonjs": true,
        "es6": false,
        "node": true
    },
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "sourceType": "script"
    },
    "rules": {
        "no-const-assign": "warn",
        "no-this-before-super": "warn",
        "no-undef": "warn",
        "no-unreachable": "warn",
        "no-unused-vars": "warn",
        "constructor-super": "warn",
        "valid-typeof": "warn"
    }
}

What did you do? Please include the actual source code causing the issue.

Here is a small snippet that should be able to be copy-pasted into a new file to replicate the issue:

function runScript(jOrderNum, jShipDate, jInitials, jOverruns) {
    /********** Preprocessor Directives **********/
    //@strict on
    //@target indesign
    //@targetengine "session"
    //@include "logging.jsxinc"

    /********** Output Script v6.50 by Chris McGee **********/
    /****************** Updated 09/20/2016 ******************/
    var windowTitle = "Output Script v6.50 by Chris McGee";
    var finalValue = 31; // The final value of the progress bar window.
    var debug = true; // If set to true, enable all $.writeln()s.
    var printSpecs = false; // Spec sheets will/will not be printed.
    var printOutput = false; // Output pages (Pad, Screen) will/will not be printed.
}

runScript("123456", "2016-10-15", "CM", "true");

And, of course, something strange is happening when I paste it here. I will try to attach the full .jsx file where the problem is occurring:

OutputJ.jsx.zip

What did you expect to happen? I expected that there might be some linting warnings/errors, but not so many at the beginning of the file, and all giving me false information about indenting.

What actually happened? Please include the actual, raw output from ESLint. Every single line that is not a comment is throwing a linting warning that the expected indentation is 1, but it found 0. This is false, as I have made sure there is definitely one tab’s worth of spacing (4 spaces) before every one of the lines it is complaining about.

I cannot paste the raw output from ESLint, since it is showing up as a list in the Problems pane of VS Code. With some step-by-step guidance on how to do this from the CLI, I could most likely get what you need.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
not-an-aardvarkcommented, Sep 21, 2016

This is false, as I have made sure there is definitely one tab’s worth of spacing (4 spaces) before every one of the lines it is complaining about

I think the issue is that your config is trying to find actual tabs, not one tab’s worth of spacing. It’s giving that error message because your files are indented with 0 tabs (and 4 spaces).

In the next version of ESLint, the error message will be a bit clearer (see #7076). In your case it would be something like “Expected indentation of 1 tab but found 4 spaces.”

See also: #3638. (Actually, #3638 can probably be closed now that #7076 fixes the error messages.)

2reactions
SturmBcommented, Sep 22, 2016

Hey, thanks for the quick reply, @not-an-aardvark!

I’m glad to see that such an update regarding indentation is definitely in the works, but that still leaves a question: Why is ESLint expecting a tab? I’ve already set the file to “Indent Using Spaces” in the Command Palette of VS Code, and it doesn’t have these indentation warnings on another file that starts out in the exact same way (attached: ProofJ.jsx.zip), and uses the same Indent Using Spaces setting. As far as I can tell, ESLint should be expecting 4 spaces, not 1 tab. (I mean, if I have to go back to using tabs for indention, I’ll gladly do so, as long as it satisfies the linter.)

EDIT: I discovered why the other file (ProofJ.jsx) wasn’t throwing those same messages. Turns out it uses a special XML syntax on line 6634 that is used by ExtendScript, but which breaks the linter’s parser. Comment out that line, and those same indentation warnings appear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What should I do with "Unexpected indent" in Python?
If you got an unexpected indent and you see that all the code is perfectly indented, try opening it with another editor and...
Read more >
Indentation Error in Python | How to Solve it - Edureka
This article will provide you with a detailed understanding of Indentation error in Python and the solutions to avoid the same.
Read more >
PEP-8: over-indented warning on correct ... - YouTrack
Yeah, I found out that you can hit Alt-Enter when the cursor is on the offending squiggly, and select "Ignore errors like this"....
Read more >
Misleading indentation - IBM
Solution: The compiler detected inconsistent indentation in the source code. Correct the indentation or explicitly group statements that are associated with the ...
Read more >
Warning for Beginners... Indentation errors are a pain ... - Reddit
Just a warning for beginners... If you tab, or just press the space bar four times, make sure you do the same thing...
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