Indentation warnings when the indentation is correct?
See original GitHub issueTell 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:
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:
- Created 7 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
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.)
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.