@guest-hyperchain/eslint-config-xzymodule-base
ESLint Shareable Config - from hyperchain(https://www.hyperchain.cn/)
Last updated 2 years ago by guest-hyperchain .
MIT · Original npm · Tarball · package.json
$ cnpm install @guest-hyperchain/eslint-config-xzymodule-base 
SYNC missed versions from official npm registry.

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

rule description
no-compare-neg-zero disallow comparing against -0
no-cond-assign disallow assignment operators in conditional expressions
no-constant-condition disallow constant expressions in conditions
no-control-regex disallow control characters in regular expressions
no-debugger disallow the use of debugger
no-dupe-args disallow duplicate arguments in function definitions
no-dupe-keys disallow duplicate keys in object literals
no-duplicate-case disallow duplicate case labels
no-empty-character-class disallow empty character classes in regular expressions
no-ex-assign disallow reassigning exceptions in catch clauses
no-extra-boolean-cast disallow unnecessary boolean casts
no-extra-parens disallow unnecessary parentheses
no-func-assign disallow reassigning function declarations
no-inner-declarations disallow variable or function declarations in nested blocks
no-invalid-regexp disallow invalid regular expression strings in RegExp constructors
no-irregular-whitespace disallow irregular whitespace outside of strings and comments
no-obj-calls disallow calling global object properties as functions
no-regex-spaces disallow multiple spaces in regular expressions
no-sparse-arrays disallow sparse arrays
no-template-curly-in-string disallow template literal placeholder syntax in regular strings
no-unexpected-multiline disallow confusing multiline expressions
no-unreachable disallow unreachable code after return, throw, continue, and break statements
no-unsafe-finally disallow control flow statements in finally blocks
no-unsafe-negation disallow negating the left operand of relational operators
use-isnan require calls to isNaN() when checking for NaN
valid-typeof enforce comparing typeof expressions against valid strings

Best Practices

rule description
accessor-pairs enforce getter and setter pairs in objects
curly enforce consistent brace style for all control statements
dot-location enforce consistent newlines before and after dots
eqeqeq require the use of === and !==
no-caller disallow the use of arguments.caller or arguments.callee
no-empty-pattern disallow empty destructuring patterns
no-eval disallow the use of eval()
no-extend-native disallow extending native types
no-extra-bind disallow unnecessary calls to .bind()
no-fallthrough disallow fallthrough of case statements
no-floating-decimal disallow leading or trailing decimal points in numeric literals
no-global-assign disallow assignments to native objects or read-only global variables
no-implied-eval disallow the use of eval()-like methods
no-iterator disallow the use of the iterator property
no-labels disallow labeled statements
no-lone-blocks disallow unnecessary nested blocks
no-multi-spaces disallow multiple spaces
no-multi-str disallow multiline strings
no-new disallow new operators outside of assignments or comparisons
no-new-func disallow new operators with the Function object
no-new-wrappers disallow new operators with the String, Number, and Boolean objects
no-octal disallow octal literals
no-octal-escape disallow octal escape sequences in string literals
no-proto disallow the use of the proto property
no-redeclare disallow variable redeclaration
no-return-assign disallow assignment operators in return statements
no-return-await disallow unnecessary return await
no-self-assign disallow assignments where both sides are exactly the same
no-self-compare disallow comparisons where both sides are exactly the same
no-sequences disallow comma operators
no-throw-literal disallow throwing literals as exceptions
no-unmodified-loop-condition disallow unmodified loop conditions
no-unused-expressions disallow unused expressions
no-useless-call disallow unnecessary calls to .call() and .apply()
no-useless-escape disallow unnecessary escape characters
no-useless-return disallow redundant return statements
no-with disallow with statements
prefer-promise-reject-errors require using Error objects as Promise rejection reasons
wrap-iife require parentheses around immediate function invocations
yoda require or disallow “Yoda” conditions

Variables

rule description
no-delete-var disallow deleting variables
no-label-var disallow labels that share a name with a variable
no-shadow-restricted-names disallow identifiers from shadowing restricted names
no-undef disallow the use of undeclared variables unless mentioned in /*global */ comments
no-undef-init disallow initializing variables to undefined
no-unused-vars disallow unused variables
no-use-before-define disallow the use of variables before they are defined

Node.js and CommonJS

rule description
handle-callback-err require error handling in callbacks
no-new-require disallow new operators with calls to require
no-path-concat disallow string concatenation with __dirname and __filename

Stylistic Issues

rule description
block-spacing disallow or enforce spaces inside of blocks after opening block and before closing block
brace-style enforce consistent brace style for blocks
camelcase enforce camelcase naming convention
comma-dangle require or disallow trailing commas
comma-spacing enforce consistent spacing before and after commas
comma-style enforce consistent comma style
eol-last require or disallow newline at the end of files
func-call-spacing require or disallow spacing between function identifiers and their invocations
indent enforce consistent indentation
key-spacing enforce consistent spacing between keys and values in object literal properties
keyword-spacing enforce consistent spacing before and after keywords
new-cap require constructor names to begin with a capital letter
new-parens require parentheses when invoking a constructor with no arguments
no-array-constructor disallow Array constructors
no-mixed-operators disallow mixed binary operators
no-mixed-spaces-and-tabs disallow mixed spaces and tabs for indentation
no-multiple-empty-lines disallow multiple empty lines
no-new-object disallow Object constructors
no-tabs disallow all tabs
no-trailing-spaces disallow trailing whitespace at the end of lines
no-unneeded-ternary disallow ternary operators when simpler alternatives exist
no-whitespace-before-property disallow whitespace before properties
object-curly-spacing enforce consistent spacing inside braces
object-property-newline enforce placing object properties on separate lines
one-var enforce variables to be declared either together or separately in functions
operator-linebreak enforce consistent linebreak style for operators
padded-blocks require or disallow padding within blocks
quotes enforce the consistent use of either backticks, double, or single quotes
semi require or disallow semicolons instead of ASI
semi-spacing enforce consistent spacing before and after semicolons
space-before-blocks enforce consistent spacing before blocks
space-before-function-paren enforce consistent spacing before function definition opening parenthesis
space-in-parens enforce consistent spacing inside parentheses
space-infix-ops require spacing around infix operators
space-unary-ops enforce consistent spacing before or after unary operators
spaced-comment enforce consistent spacing after the // or /* in a comment
template-tag-spacing require or disallow spacing between template tags and their literals
unicode-bom require or disallow Unicode byte order mark (BOM)

ECMAScript 6

rule description
arrow-spacing enforce consistent spacing before and after the arrow in arrow functions
constructor-super require super() calls in constructors
generator-star-spacing enforce consistent spacing around * operators in generator functions
no-class-assign disallow reassigning class members
no-const-assign disallow reassigning const variables
no-dupe-class-members disallow duplicate class members
no-new-symbol disallow new operators with the Symbol object
no-this-before-super disallow this/super before calling super() in constructors
no-useless-computed-key disallow unnecessary computed property keys in object literals
no-useless-constructor disallow unnecessary constructors
no-useless-rename disallow renaming import, export, and destructured assignments to the same name
rest-spread-spacing enforce spacing between rest and spread operators and their expressions
symbol-description require symbol descriptions
template-curly-spacing require or disallow spacing around embedded expressions of template strings
yield-star-spacing require or disallow spacing around the * in yield* expressions

Other Rules

eslint-plugin-react

rule description
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-prop children 不能作为组件的 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

rule description
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 对应属性
scope scope 属性只能出现在 th 标签下
tabindex-no-positive 禁止使用正数的tabindex

eslint-plugin-import

rule description
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.

Current Tags

  • 0.1.1                                ...           latest (2 years ago)

1 Versions

  • 0.1.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |