Giter VIP home page Giter VIP logo

eslint-plugin-padding's Introduction

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_TYPE is 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_TYPE is one (or an array) of the following:

    1. A space-delimited list of keyword (e.g. "const", "export const", or "class")

    2. 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) { }, and while (a) { }. Also matches immediately invoked function expression statements.
      • "exports" - export statements of CommonJS; e.g. module.exports = 0, module.exports.foo = 1, and exports.foo = 2.
      • "require" - require statements 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_TYPE is the name of an ESTree node type, e.g. "FunctionDeclaration". You can use an AST explorer to get the name of a particular node.
      • KEYWORD is 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.

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

eslint-plugin-padding's People

Contributors

jun-sheaf avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

photon79

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.