0.0.4 • Published 5 years ago
eslint-plugin-padding v0.0.4
eslint-plugin-padding
This rule allows/disallows spacing between two given statements. Spacing generally helps
readability. This rule is a generalized version of the
eslint/padding-line-between-statements
rule and can also be used to replace
eslint/lines-between-class-members.
Syntax
{
"padding/spacing": [
"error",
{ "blankLine": LINEBREAK_TYPE, "prev": STATEMENT_TYPE, "next": STATEMENT_TYPE },
{ "blankLine": LINEBREAK_TYPE, "prev": STATEMENT_TYPE, "next": STATEMENT_TYPE },
{ "blankLine": LINEBREAK_TYPE, "prev": STATEMENT_TYPE, "next": STATEMENT_TYPE },
{ "blankLine": LINEBREAK_TYPE, "prev": STATEMENT_TYPE, "next": STATEMENT_TYPE },
...
]
}LINEBREAK_TYPEis one of the following."any"just ignores the statement pair."never"disallows blank lines."always"requires one or more blank lines. Note it does not count lines that comments exist as blank lines. te it does not count lines that comments exist as blank lines.
STATEMENT_TYPEis one (or an array) of the following:- A space-delimited list of keyword (e.g.
"const","export const", or"class") One of the following:
"*"is wildcard. This matches any statements."block-like"- block like statements. This matches statements that the last token is the closing brace of blocks; e.g.{ },if (a) { }, andwhile (a) { }. Also matches immediately invoked function expression statements."exports"-exportstatements of CommonJS; e.g.module.exports = 0,module.exports.foo = 1, andexports.foo = 2."require"-requirestatements of CommonJS; e.g.const foo = require("foo")."directive"- directive prologues. This matches directives; e.g."use strict"."iife"- immediately invoked function expression statements. This matches calls on a function expression, optionally prefixed with a unary operator.
An object of the form
{ "type": NODE_TYPE | undefined, "keyword": KEYWORD | undefined, "inline": boolean | undefined "comment": boolean | 'line' | 'block' | undefined }where
NODE_TYPEis the name of anESTreenode type, e.g."FunctionDeclaration". You can use anAST explorerto get the name of a particular node.KEYWORDis one (or an array) of either (i) or (ii)."inline"is a flag that denotes the node must span multiple lines (false) or a single line (true)"comment"specifies the particular node has a comment before it. String options declare a specific type.
- A space-delimited list of keyword (e.g.
When Not To Use It
If you don't want to notify warnings about linebreaks, then it's safe to disable this rule.
Taken with ❤️ from ESLint core