Add a --fix option for no-tabs
See original GitHub issueI’m using Node v6.4.0 and ESLint v3.3.1.
I think it would be useful to have an autofix option for the no-tabs
rule. The fixer would simply delete any tab characters that it finds, inserting a space if necessary to avoid modifying the AST. (For example, var\tfoo
would be replaced with var foo
, since replacing it with varfoo
would change the semantics of the program)
This would also provide a workaround for https://github.com/eslint/eslint/issues/4274; if all tabs were removed from the file, then the indent
autofix could clean up and produce correct output on the next pass.
I would be willing to add this if the issue is accepted.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:18 (18 by maintainers)
Top Results From Across the Web
No tabs or Ribbon or any extra features - Microsoft Community
I was trying to add a template for work and I needed the new item tab, I dont have this or any tab,...
Read more >Eslint expected indentation of 1 tab but found 4 spaces error
In the settings, click: Text Editor after that, uncheck the Insert Space option and the Detect Indentation option as shown in the following ......
Read more >indent - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Solved: No Tabs? - Adobe Acrobat Pro DC - 9355273
Solved: So i know there has been some post here on how to find tab option. (General>Preference>Open New doc as Tab) But my...
Read more >Can You Choose to have No Tabs Active on the Tabs Element?
Please add a class to the tab elements you do not want to have an opened tab then add this code in X...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Alaneor Unfortunately, rules are designed not to be able to know anything about other rules in ESLint, so looking at
indent
configuration is a non-starter. (Consider that users might not even useindent
, so there wouldn’t be a configuration to inspect.) Luckily, for those who do care, multipass auto-fix allows theindent
issues to be fixed on a later pass.Thanks for clarifying; that makes more sense now.
I think we can classify tabs into three different categories:
Ideally, this would be handled by the
indent
autofix, since that rule has access to the user’s preferred indentation. In other words, theindent
fixer would be able to delete/add indentation tabs as necessary to ensure that a line’s indentation is correct. (This is also discussed in https://github.com/eslint/eslint/issues/4274.)I think it would be safe for ESLint to replace these tabs with
\t
. There are other ways to represent a tab character in JS (\x09
,\u0009
,\011
), but I don’t think this replacement would surprise people. (Admittedly, we can’t be 100% certain of which tab representation people would actually want.)function\tfoo () {}
Tabs in this context aren’t fixed by any other rule. While it would be possible to remove these tabs and replace them with a space, the user might not expect this particular fix. I think this category of tabs is fairly rare (in fact, I’ve never actually seen anyone use tabs like this) so it’s hard to say whether the user would be surprised by a fix to these tabs.
edit: fixed typo
\x0009
-->\u0009