非常教程

Eslint参考手册

规则 | Rules

no-dupe-keys

配置文件中的"extends": "eslint:recommended"属性启用此规则。

对象文字中具有相同键的多个属性可能会导致应用程序出现意外行为。

var foo = {
    bar: "baz",
    bar: "qux"
};

规则细节

此规则不允许在对象文字中使用重复键。

此规则的错误代码示例:

/*eslint no-dupe-keys: "error"*/

var foo = {
    bar: "baz",
    bar: "qux"
};

var foo = {
    "bar": "baz",
    bar: "qux"
};

var foo = {
    0x1: "baz",
    1: "qux"
};

此规则的正确代码示例:

/*eslint no-dupe-keys: "error"*/

var foo = {
    bar: "baz",
    quxx: "qux"
};

版本

该规则在 ESLint 0.0.9中引入。

资源

  • 规则资源
  • 文档资源

规则 | Rules相关

1.yoda
2.yield-star-spacing
3.wrap-regex
4.wrap-iife
5.vars-on-top
6.valid-typeof
7.valid-jsdoc
8.use-isnan
9.unicode-bom
10.template-tag-spacing
11.template-curly-spacing
12.symbol-description
13.switch-colon-spacing
14.strict
15.spaced-line-comment
16.spaced-comment
17.space-unary-word-ops
18.space-unary-ops
19.space-return-throw-case
20.space-infix-ops
21.space-in-parens
22.space-in-brackets
23.space-before-keywords
24.space-before-function-parentheses
25.space-before-function-paren
26.space-before-blocks
27.space-after-keywords
28.space-after-function-name
29.sort-vars
30.sort-keys
31.sort-imports
32.semi-style
33.semi-spacing
34.semi
35.Rules
36.rest-spread-spacing
37.require-yield
38.require-jsdoc
39.require-await
40.radix
41.quotes
42.quote-props
43.prefer-template
44.prefer-spread
45.prefer-rest-params
46.prefer-reflect
47.prefer-promise-reject-errors
48.prefer-numeric-literals
49.prefer-destructuring
50.prefer-const
51.prefer-arrow-callback
52.padding-line-between-statements
53.padded-blocks
54.operator-linebreak
55.operator-assignment
56.one-var-declaration-per-line
57.one-var
58.object-shorthand
59.object-property-newline
60.object-curly-spacing
61.object-curly-newline
62.nonblock-statement-body-position
63.no-wrap-func
64.no-with
65.no-whitespace-before-property
66.no-warning-comments
67.no-void
68.no-var
69.no-useless-return
70.no-useless-rename
71.no-useless-escape
72.no-useless-constructor
73.no-useless-concat
74.no-useless-computed-key
75.no-useless-call
76.no-use-before-define
77.no-unused-vars
78.no-unused-labels
79.no-unused-expressions
80.no-unsafe-negation
81.no-unsafe-finally
82.no-unreachable
83.no-unneeded-ternary
84.no-unmodified-loop-condition
85.no-unexpected-multiline
86.no-underscore-dangle
87.no-undefined
88.no-undef-init
89.no-undef
90.no-trailing-spaces
91.no-throw-literal
92.no-this-before-super
93.no-ternary
94.no-template-curly-in-string
95.no-tabs
96.no-sync
97.no-sparse-arrays
98.no-spaced-func
99.no-space-before-semi
100.no-shadow-restricted-names
Eslint

ESLint 是一个代码规范和错误检查工具,有以下几个特性。所有东西都是可以插拔的。你可以调用任意的 rule api 或者 formatter api 去打包或者定义 rule or formatter。任意的 rule 都是独立的。没有特定的 coding style,你可以自己配置。

主页 https://eslint.org/
源码 https://github.com/eslint/eslint
发布版本 4.12.0

Eslint目录

1.指南 | Guide
2.规则 | Rules