0.1.1 • Published 5 years ago

eslint-config-xzymodule-base v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

eslint-config-hyperchain

travis npm MIT

ESLint Shareable Config For React App

Installation

Install peerDependencies.

# npm
npm install eslint eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react  --save-dev

# yarn
yarn add eslint eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react --dev

Install This Config

# npm 
npm install eslint-config-hyperchain --save-dev 

# yarn 
yarn add eslint-config-hyperchain --dev

Configuration

Configure the following content in .eslintrc.js

  "extends": [
    "hyperchain"
  ]

Base Rules

Possible Errors

ruledescription
no-compare-neg-zerodisallow comparing against -0
no-cond-assigndisallow assignment operators in conditional expressions
no-constant-conditiondisallow constant expressions in conditions
no-control-regexdisallow control characters in regular expressions
no-debuggerdisallow the use of debugger
no-dupe-argsdisallow duplicate arguments in function definitions
no-dupe-keysdisallow duplicate keys in object literals
no-duplicate-casedisallow duplicate case labels
no-empty-character-classdisallow empty character classes in regular expressions
no-ex-assigndisallow reassigning exceptions in catch clauses
no-extra-boolean-castdisallow unnecessary boolean casts
no-extra-parensdisallow unnecessary parentheses
no-func-assigndisallow reassigning function declarations
no-inner-declarationsdisallow variable or function declarations in nested blocks
no-invalid-regexpdisallow invalid regular expression strings in RegExp constructors
no-irregular-whitespacedisallow irregular whitespace outside of strings and comments
no-obj-callsdisallow calling global object properties as functions
no-regex-spacesdisallow multiple spaces in regular expressions
no-sparse-arraysdisallow sparse arrays
no-template-curly-in-stringdisallow template literal placeholder syntax in regular strings
no-unexpected-multilinedisallow confusing multiline expressions
no-unreachabledisallow unreachable code after return, throw, continue, and break statements
no-unsafe-finallydisallow control flow statements in finally blocks
no-unsafe-negationdisallow negating the left operand of relational operators
use-isnanrequire calls to isNaN() when checking for NaN
valid-typeofenforce comparing typeof expressions against valid strings

Best Practices

ruledescription
accessor-pairsenforce getter and setter pairs in objects
curlyenforce consistent brace style for all control statements
dot-locationenforce consistent newlines before and after dots
eqeqeqrequire the use of === and !==
no-callerdisallow the use of arguments.caller or arguments.callee
no-empty-patterndisallow empty destructuring patterns
no-evaldisallow the use of eval()
no-extend-nativedisallow extending native types
no-extra-binddisallow unnecessary calls to .bind()
no-fallthroughdisallow fallthrough of case statements
no-floating-decimaldisallow leading or trailing decimal points in numeric literals
no-global-assigndisallow assignments to native objects or read-only global variables
no-implied-evaldisallow the use of eval()-like methods
no-iteratordisallow the use of the iterator property
no-labelsdisallow labeled statements
no-lone-blocksdisallow unnecessary nested blocks
no-multi-spacesdisallow multiple spaces
no-multi-strdisallow multiline strings
no-newdisallow new operators outside of assignments or comparisons
no-new-funcdisallow new operators with the Function object
no-new-wrappersdisallow new operators with the String, Number, and Boolean objects
no-octaldisallow octal literals
no-octal-escapedisallow octal escape sequences in string literals
no-protodisallow the use of the proto property
no-redeclaredisallow variable redeclaration
no-return-assigndisallow assignment operators in return statements
no-return-awaitdisallow unnecessary return await
no-self-assigndisallow assignments where both sides are exactly the same
no-self-comparedisallow comparisons where both sides are exactly the same
no-sequencesdisallow comma operators
no-throw-literaldisallow throwing literals as exceptions
no-unmodified-loop-conditiondisallow unmodified loop conditions
no-unused-expressionsdisallow unused expressions
no-useless-calldisallow unnecessary calls to .call() and .apply()
no-useless-escapedisallow unnecessary escape characters
no-useless-returndisallow redundant return statements
no-withdisallow with statements
prefer-promise-reject-errorsrequire using Error objects as Promise rejection reasons
wrap-iiferequire parentheses around immediate function invocations
yodarequire or disallow “Yoda” conditions

Variables

ruledescription
no-delete-vardisallow deleting variables
no-label-vardisallow labels that share a name with a variable
no-shadow-restricted-namesdisallow identifiers from shadowing restricted names
no-undefdisallow the use of undeclared variables unless mentioned in /global / comments
no-undef-initdisallow initializing variables to undefined
no-unused-varsdisallow unused variables
no-use-before-definedisallow the use of variables before they are defined

Node.js and CommonJS

ruledescription
handle-callback-errrequire error handling in callbacks
no-new-requiredisallow new operators with calls to require
no-path-concatdisallow string concatenation with dirname and filename

Stylistic Issues

ruledescription
block-spacingdisallow or enforce spaces inside of blocks after opening block and before closing block
brace-styleenforce consistent brace style for blocks
camelcaseenforce camelcase naming convention
comma-danglerequire or disallow trailing commas
comma-spacingenforce consistent spacing before and after commas
comma-styleenforce consistent comma style
eol-lastrequire or disallow newline at the end of files
func-call-spacingrequire or disallow spacing between function identifiers and their invocations
indentenforce consistent indentation
key-spacingenforce consistent spacing between keys and values in object literal properties
keyword-spacingenforce consistent spacing before and after keywords
new-caprequire constructor names to begin with a capital letter
new-parensrequire parentheses when invoking a constructor with no arguments
no-array-constructordisallow Array constructors
no-mixed-operatorsdisallow mixed binary operators
no-mixed-spaces-and-tabsdisallow mixed spaces and tabs for indentation
no-multiple-empty-linesdisallow multiple empty lines
no-new-objectdisallow Object constructors
no-tabsdisallow all tabs
no-trailing-spacesdisallow trailing whitespace at the end of lines
no-unneeded-ternarydisallow ternary operators when simpler alternatives exist
no-whitespace-before-propertydisallow whitespace before properties
object-curly-spacingenforce consistent spacing inside braces
object-property-newlineenforce placing object properties on separate lines
one-varenforce variables to be declared either together or separately in functions
operator-linebreakenforce consistent linebreak style for operators
padded-blocksrequire or disallow padding within blocks
quotesenforce the consistent use of either backticks, double, or single quotes
semirequire or disallow semicolons instead of ASI
semi-spacingenforce consistent spacing before and after semicolons
space-before-blocksenforce consistent spacing before blocks
space-before-function-parenenforce consistent spacing before function definition opening parenthesis
space-in-parensenforce consistent spacing inside parentheses
space-infix-opsrequire spacing around infix operators
space-unary-opsenforce consistent spacing before or after unary operators
spaced-commentenforce consistent spacing after the // or /* in a comment
template-tag-spacingrequire or disallow spacing between template tags and their literals
unicode-bomrequire or disallow Unicode byte order mark (BOM)

ECMAScript 6

ruledescription
arrow-spacingenforce consistent spacing before and after the arrow in arrow functions
constructor-superrequire super() calls in constructors
generator-star-spacingenforce consistent spacing around * operators in generator functions
no-class-assigndisallow reassigning class members
no-const-assigndisallow reassigning const variables
no-dupe-class-membersdisallow duplicate class members
no-new-symboldisallow new operators with the Symbol object
no-this-before-superdisallow this/super before calling super() in constructors
no-useless-computed-keydisallow unnecessary computed property keys in object literals
no-useless-constructordisallow unnecessary constructors
no-useless-renamedisallow renaming import, export, and destructured assignments to the same name
rest-spread-spacingenforce spacing between rest and spread operators and their expressions
symbol-descriptionrequire symbol descriptions
template-curly-spacingrequire or disallow spacing around embedded expressions of template strings
yield-star-spacingrequire or disallow spacing around the in yield expressions

Other Rules

eslint-plugin-react

ruledescription
react/display-name禁止在 React 组件定义中丢失 displayName
react/jsx-key在数组或迭代器中验证 JSX 具有 key 属性
react/jsx-no-comment-textnodes禁止注解被插入到文本节点
react/jsx-no-duplicate-props禁止在 JSX 中重复的 props
react/jsx-no-target-blank禁止使用不安全的 blank 标签
react/jsx-no-undef在 JSX 中禁止未声明的变量
react/jsx-uses-react禁止 React 被错误地标记为未使用
react/jsx-uses-vars防止在 JSX 中使用的变量被错误地标记为未使用
react/no-children-propchildren 不能作为组件的 props 去传入
react/no-danger-with-children禁止组件同时存在 children 和 props.dangerouslySetInnerHTML
react/no-deprecated禁止使用弃用的方法
react/no-direct-mutation-state禁止 state 直接赋值,强制采用 setState 方法改变 state 的值
react/no-find-dom-node禁止使用 findDOMNode 来获取dom元素
react/no-is-mounted禁止使用 isMounted
react/no-render-return-value禁止在 React.render 返回值
react/no-string-refs禁止使用字符串的 ref
react/no-unescaped-entities禁止出现类似 JSX 中转义字符的非法字符,比如 { < ' ''
react/no-unknown-property禁止使用未知的 DOM 属性
react/prop-types防止在 React 组件定义中丢失 props 验证
react/react-in-jsx-scope使用 JSX 时防止丢失 React
react/require-render-return强制es5或者es6在 render 时 return 一个值

eslint-plugin-jsx-a11y

ruledescription
accessible-emoji强制表情被包含在 span 标签中,同时申明属性 role="img" 与有效的描述
alt-text强制所有需要替换文本的元素都具有有意义的信息
anchor-has-content强制 a 标签有内容且内容可以被阅读者访问
anchor-is-valid禁止使用无意义的 a 标签
aria-activedescendant-has-tabindex在使用 activedescendant 的时候强制要求使用属性 tabindex
aria-props禁止元素使用非法的 aria 属性
aria-proptypes禁止非法的 aria 状态与属性值
aria-role禁止元素使用非法的 aria-role 属性值
aria-unsupported-elements禁止某些保留 DOM 元素使用 role 或者 aria-* 属性
click-events-have-key-events强制在点击事件出现时,出现键盘事件 onKeyUp ,onKeyDown, onKeyPress 中的一个
heading-has-content强制 h 标签有内容且内容可以被阅读者访问
html-has-lang强制要求 html 标签有 lang 属性
iframe-has-title强制 iframe 元素有 title 属性
img-redundant-alt禁止在 img 标签的 alt 属性值中包含没有意义的文本,例如 image , photo 或者 picture
interactive-supports-focus强制涉及交互的元素必须要能够获取焦点
label-has-for强制 label 标签有关联的控制
lang禁止非法的 lang 属性值
media-has-caption媒体标签必须包含 captions
mouse-events-have-key-events强制 onmouseover()/onmouseout() 方法始终伴随着 onfocus()/onblur() 方法
no-access-key强制元素不带有 accessKey 属性
no-autofocus强制元素不带有 autoFocus 属性
no-distracting-elements禁止出现定义过的非法元素
no-interactive-element-to-noninteractive-role强制要求非交互元素要有非交互的 role 元素对应
no-noninteractive-element-interactions强制涉及交互的元素有相应的交互的 aria 属性
no-noninteractive-element-to-interactive-role禁止非交互的元素具有一个交互的 aria 属性
no-noninteractive-tabindex禁止在无序列列表中添加 tabindex
no-onchange禁止直接使用 onchange , 可以用 onblur 事件代替或者让 onblur 事件同时出现
no-redundant-roles禁止使用冗余的 aria
no-static-element-interactions在为静态元素添加交互事件时,强制要求元素被给予 role 属性
role-has-required-aria-props强制要求具有 role 属性的元素具有当前role 对应的所有属性
role-supports-aria-props强制要求具有 role 属性的元素有且只能有当前 role 对应属性
scopescope 属性只能出现在 th 标签下
tabindex-no-positive禁止使用正数的tabindex

eslint-plugin-import

ruledescription
no-unresolved确保导入的路径指向可解析的文件或者模块
named确保命名导入的文件对应于相应命名的远程文件
default在给定默认导入的情况下,确保出现默认导出
namespace
no-restricted-paths限制哪些文件可以被导入到给定的文件中
no-absolute-path禁止使用绝对路径导入文件
no-dynamic-require禁止 require() 方法中写入表达式
no-internal-modules禁止导入其他模块的子模块
no-webpack-loader-syntax禁止导入时使用 webpack loader 语法
no-self-import禁止导入模块本身
no-cycle确保导出的模块不是来自导入的模块
no-useless-path-segments阻止 import 与 require 时不必要的路径段
no-relative-parent-imports禁止导入到相对父路径中的文件夹
export提示所有非法的导出
no-named-as-default提示默认导出文件名称与需要导入的名称不符
no-named-as-default-member提示导出的名称已经存在,不是默认的导出名称
no-deprecated提示弃用的 name
no-extraneous-dependencies禁止使用无关的依赖包
no-mutable-exports禁止使用可变的导出,例如使用 var,let
unambiguous报告可能不明确的解析目标
no-commonjs禁止使用 commonjs 模块化方案
no-amd禁止 amd 模块化方案
no-nodejs-modules禁止使用 node 自带的模块
first确保所有导入都出现在其他语句之前
exports-last确保所有导出都出现在其他语句之后
no-duplicates报告同一模块在多个位置的重复导入
no-namespace报告重复使用的命名空间
extensions确保导入路径中,文件扩展名的一致使用
order强制约定一种导入的顺序
newline-after-import在 import 语句后强制要求空一行
prefer-default-export如果只有一个模块,推荐使用 default export 进行导出
max-dependencies限制一个模块可以拥有的依赖的最大数量
no-unassigned-import禁止没有赋值的导入
no-named-default报告使用 default export 作为本地命名的导入
no-default-export禁止 default export
no-anonymous-default-export禁止匿名值作为默认导出
group-exports优先将多个导出的模块合并成一个组,而不是一个个单独导出。
dynamic-import-chunkname报告所有的没有经过 webpackChunkName 指定的导入

License

eslint-congfig-hyperchain is licensed under the MIT License.