Article From:https://www.cnblogs.com/fqh123/p/9967771.html

eslintIt’s good to check the code style, but it’s annoying to have some line breaks, blank errors, and console errors in the code.

To prohibit these annoying errors

We can find it in the package. JSON file.

“eslintConfig”: {
  ”root”: true,
  ”env”: {
    ”node”: true
  },
  ”extends”: [
    ”plugin:vue/essential”,
    ”eslint:recommended”
  ],
  ”rules”: {
    ”no-console”:”off”,//Forbid console error checking here
    ”no-irregular-whitespace”:”off”//This prohibits checking for missing blanks and errors
  },
  ”parserOptions”: {
    ”parser”: “babel-eslint”
  }
},
//Prohibit these rules in rules rules
 
Here are some of the implications of some rules:
“off” or 0 – Close (Disable) Rules
“warn” or 1 – Consider the rule as a warning (which does not lead to failure of the check)
“error” or 2 – Consider the rule as an error (exit code 1, check failed)
 

.Common rules
Class description
Possible Errors Possible errors or logical errors
no-cond-assign Prohibit ambiguous assignment operators in conditional expressions
no-console Disable console
no-constant-condition Prohibit Constant Expressions in Conditions
no-debugger Disable debugger
no-dupe-args Disallowing rename parameters in function definitions
no-dupe-keys Prohibit duplicate keys in object literals
no-duplicate-case Prohibit duplicate case Tags
no-empty Prohibit empty statement blocks
no-ex-assign It is forbidden to reassign the parameters of the catch clause
no-extra-boolean-cast Prohibiting Unnecessary Boolean Conversion
no-extra-parens Prohibit unnecessary brackets
no-extra-semi Prohibit unnecessary semicolons
no-func-assign Prohibit reassignment of function declarations
no-inner-declarations Disallow variable declarations or function declarations in nested blocks
no-irregular-whitespace Prohibit irregular blanks outside strings and comments
no-obj-calls Prohibit global objects as function calls
no-sparse-arrays Disable sparse arrays
no-prototype-builtins Prohibit direct use of the built-in properties of Object. prototypes
no-unexpected-multiline Prohibit confusing multiline expressions
no-unreachable Prohibit unreachable code after return, throw, continue and break statements
use-isnan Require the use of isNaN () to check NaN
valid-typeof Compare mandatory typeof expressions with valid strings
—– —–
Best Practices Best practices
array-callback-return There is a return statement in the callback function of the mandatory array method
block-scoped-var Force the use of variables within the scope of their definition
complexity Maximum Loop Complexity Allowed in a Specified Program
consistent-return Require the return statement to either always specify the return value or not
curly Force all control statements to use consistent parentheses
default-case Require default branches in switch statements
dot-location Force line changes that are consistent before and after the dot
dot-notation Force the use of dots whenever permitted
eqeqeq Require the use of === and!===
guard-for-in Require an IF statement in the for-in loop
no-alert Disable alert, confirm, and prompt
no-case-declarations Lexical declarations are not allowed in case clauses
no-else-return Forbid if statement having return followed by else
no-empty-function Prohibit empty functions
no-eq-null Prohibit comparisons with null without type checking operators
no-eval Disable Eval ()
no-extra-bind Prohibit unnecessary. bind () calls
no-fallthrough Prohibit case statements from failing
no-floating-decimal Prohibit the use of leading and ending decimal points in digital literals
no-implicit-coercion Prohibit type conversion using short symbols
no-implicit-globals Prohibit global use of VaR and named function declarations
no-invalid-this: Prohibit this keyword from appearing outside classes and class objects
no-lone-blocks Disable unnecessary nested blocks
no-loop-func Prohibit function declarations and expressions in loops
no-magic-numbers Disable magic numbers
no-multi-spaces Prohibit the use of multiple spaces
no-multi-str Prohibit the use of multi-line strings
no-new Prohibit the use of new operators in non-assignment or conditional statements
no-new-func Prohibit the use of new operators on Function objects
no-new-wrappers Prohibit the use of new operators for String, Number and Boolean
no-param-reassign No reassignment of function parameters is allowed
no-redeclare Prohibit the use of VaR to declare the same variable multiple times
no-return-assign Prohibit the use of assignment statements in return statements
no-script-url Prohibit the use of javascript:url
no-self-assign Prohibiting self assignment
no-self-compare Prohibition of self comparison
no-sequences Disable comma operators
no-unmodified-loop-condition Prohibiting invariable cyclic conditions
no-unused-expressions Prohibit unused expressions
no-useless-call Prohibit unnecessary. call () and. apply ()
no-useless-concat Prohibit unnecessary connection of string literals or template literals
vars-on-top Require all var declarations to appear at the top of their scope
—– —–
Strict Mode Using strict mode and strict mode means
strict Require or prohibit the use of strict mode instructions
—– —–
Variables Variable declaration
init-declarations Require or prohibit initialization in var declarations
no-catch-shadow The parameter of the catch clause is not allowed to have the same name as the variable in the outer scope
no-restricted-globals Disable specific global variables
no-shadow Prohibit var declarations from having the same name as variables in outer scope
no-undef Disable undeclared variables unless they are mentioned in the / global / comment
no-undef-init Initialization of variables to undefined is prohibited
no-unused-vars Prohibit unused variables
no-use-before-define They are not allowed to be used before variables are defined
—– —–
Nodejs and CommonJS Node.js,CommonJS
global-require Require () to appear in the scope of the top-level module
handle-callback-err Require fault tolerance in callback functions
no-mixed-requires Prohibit mixing regular var declarations and require calls
no-new-require Prohibit the use of the new operator when calling require
no-path-concat String connections to dirname and filename are prohibited
no-restricted-modules Disable specified modules loaded through require
—– —–
Stylistic Issues Style guide
array-bracket-spacing Force the use of consistent spaces in square brackets of arrays
block-spacing Force the use of consistent spaces in single-line blocks of code
brace-style Force consistent bracket style in code blocks
camelcase Mandatory use of camel spelling naming conventions
comma-spacing Force the use of consistent spaces around commas
comma-style Mandatory use of a consistent comma style
computed-property-spacing Force the use of consistent spaces in square brackets of computed attributes
eol-last Force at least one blank line at the end of the file
func-names Force the use of named function expressions
func-style Mandatory and consistent use of function declarations or expression
indent Force consistent indentation
jsx-quotes Force the consistent use of double or single quotes in JSX attributes
key-spacing Forces the use of consistent spacing between keys and values in object literal attributes
keyword-spacing Force the use of consistent spaces before and after keywords
linebreak-style Mandatory use of consistent line-breaking styles
lines-around-comment Require blank lines around comments
max-depth Maximum depth of mandatory nestable blocks
max-len Maximum length of forced line
max-lines Forced maximum row number
max-nested-callbacks Maximum nesting depth of mandatory callback function
max-params Maximum number of permissible parameters in mandatory function definition
max-statements Force the maximum number of statements allowed for function blocks
max-statements-per-line Force the maximum number of statements allowed in each line
new-cap Require the initials of the constructor to be capitalized
new-parens Parentheses are required when calling a parametric constructor
newline-after-var Require or prohibit a blank line after a VAR declaration statement
newline-before-return Require a blank line before the return statement
newline-per-chained-call Require a newline character for each call in the method chain
no-array-constructor Prohibit the use of Array constructors
no-continue Disable continue statement
no-inline-comments Prohibit inline comments after lines of code
no-lonely-if Forbid if to appear as a unique statement in an else statement
no-mixed-spaces-and-tabs Mixed indentation of spaces and tabs is not allowed
no-multiple-empty-lines Multiple blank lines are not allowed
no-negated-condition Expressions that do not permit negation
no-plusplus Disallow the use of unary operators + + and uuuuuuuuuuu
no-spaced-func Prohibit spaces between function identifiers and parentheses
no-ternary Ternary operators are not allowed
no-trailing-spaces Disable end spaces
no-whitespace-before-property There is a blank before forbidden attributes
object-curly-newline Compulsory consistency of line breaks within curly brackets
object-curly-spacing Force the use of consistent spaces in curly braces
object-property-newline Force the attributes of objects to be placed on different lines
one-var Variables in mandatory functions are either declared together or separately
one-var-declaration-per-line Require or prohibit line changes around var declarations
operator-assignment Require or prohibit the use of simplified assignment operators where possible
operator-linebreak Force operators to use consistent newline characters
quote-props Require the literal property name of the object to be enclosed in quotation marks
quotes Force the use of consistent backticks, double or single quotes
require-jsdoc Require JSDoc annotations
semi Require or prohibit the use of semicolons instead of ASI
semi-spacing Use the same spaces before and after a forced semicolon
sort-vars Require variables in the same declaration block to be arranged in order
space-before-blocks Force the use of consistent spaces before blocks
space-before-function-paren Force the use of consistent spaces before the left parentheses of function
space-in-parens Force the use of consistent spaces in parentheses
space-infix-ops Require spaces around operators
space-unary-ops Force the use of consistent spaces before and after unary operators
spaced-comment Force the use of consistent spaces in comments //or /*

Leave a Reply

Your email address will not be published. Required fields are marked *