Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

eslint-plugin-smarter-tabs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-smarter-tabs

A tiny ESLint plugin to enforce the usage of smart tabs.

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

🎓 eslint-plugin-smarter-tabs

License Latest release Coverage status

This plugin aims to enforce the usage of smart tabs, as defined in the emacs wiki:

  • Tabs are only used at the beginning of lines. Everything else, like ASCII art and tables, should be formatted with spaces.
  • 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:

  • The line contains an inline tabulation:
ValidInvalid
const foo    = true;
const foobar = false;
const foo———𝈷= true;
const foobar = false;
  • 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:
ValidInvalid
function foo(bar) {
————𝈷return (bar === undefined)
————𝈷       ? 'foo';
————𝈷       : 'bar';
}
function foo(bar) {
————𝈷return (bar === undefined)
————𝈷————𝈷  ? 'foo';
————𝈷————𝈷  : 'bar';
}
  • 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:
ValidInvalid
if (baz) {
————𝈷let p = { x: 1,
————𝈷          y: 2,
————𝈷          z: 3,
————𝈷};
}
if (baz) {
————𝈷let p = { x: 1,
————𝈷————𝈷————𝈷y: 2,
————𝈷————𝈷————𝈷z: 3,
————𝈷};
}

Installation

npm i -D eslint-plugin-smarter-tabs

Usage

This plugin exports a single rule called smarter-tabs that you can use in your .eslintrc.json or eslintrc.js:

{
	"plugins": [
		"smarter-tabs"
	],

	"rules": {
		"smarter-tabs/smarter-tabs": "warn"
	}
}

If you use the eslint:recommended preset, you may also want to disable the no-mixed-spaces-and-tabs rule as it might clash with this plugin:

{
	"rules": {
		"no-mixed-spaces-and-tabs": "off",
		"smarter-tabs/smarter-tabs": "warn"
	}
}

Or you could pass it the smart-tabs options:

{
	"rules": {
		"no-mixed-spaces-and-tabs": ["warn", "smart-tabs"],
		"smarter-tabs/smarter-tabs": "warn"
	}
}

Changelog

See the full changelog here.

License

This software is distributed under the ISC license.

Keywords

eslint

FAQs

Package last updated on 03 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts