A tiny ESLint plugin to enforce the usage of smart tabs.
npm install eslint-plugin-smarter-tabsThis plugin aims to enforce the usage of smart tabs, as defined
in the emacs wiki:
> 1. Tabs are only used at the beginning of lines. Everything else, like ASCII
> art and tables, should be formatted with spaces.
> 2. Tabs are only used for expressing the indentation level. One tab per
> βblockβ β any remaining whitespace is spaces only.
To accomplish this, the plugin exports a single rule which issues a report in three cases:
1. The line contains an inline tabulation:
| Valid | Invalid |
|---|---|
`` | ` |
2. The line use spaces for indentation. This happens when a line is indented with
spaces or starts with tabs followed by spaces, and its indentation level is
different than the one of its block:
| Valid | Invalid |
|---|---|
` | ` |
3. The line has a mismatched indentation level. This happens when the
indentation level of the line is greater than the one of the line before it by
two or more:
| Valid | Invalid |
|---|---|
` | ` |
`shell`
npm i -D eslint-plugin-smarter-tabs
This plugin exports a single rule called smarter-tabs that you can use in your.eslintrc.json or eslintrc.js:`json
{
"plugins": [
"smarter-tabs"
],
"rules": {
"smarter-tabs/smarter-tabs": "warn"
}
}
`
If you use the eslint:recommended preset, you may also want to disable theno-mixed-spaces-and-tabs rule as it might clash with this plugin:`json`
{
"rules": {
"no-mixed-spaces-and-tabs": "off",
"smarter-tabs/smarter-tabs": "warn"
}
}smart-tabs
Or you could pass it the options:`json``
{
"rules": {
"no-mixed-spaces-and-tabs": ["warn", "smart-tabs"],
"smarter-tabs/smarter-tabs": "warn"
}
}
See the full changelog here.
This software is distributed under the ISC license.