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.

Add a --fix option for no-tabs

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
platinumazurecommented, Aug 26, 2016

@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 use indent, so there wouldn’t be a configuration to inspect.) Luckily, for those who do care, multipass auto-fix allows the indent issues to be fixed on a later pass.

1reaction
not-an-aardvarkcommented, Aug 31, 2016

Thanks for clarifying; that makes more sense now.


I think we can classify tabs into three different categories:

  • Indentation (i.e. tabs on a line before anything else):

Ideally, this would be handled by the indent autofix, since that rule has access to the user’s preferred indentation. In other words, the indent 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.)

  • Tabs in string/template/regex literals

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.)

  • Tabs as whitespace in other places, e.g. 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

Read more comments on GitHub >

github_iconTop 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 >

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