Compare commits

..

509 Commits

Author SHA1 Message Date
Jordan Harband
b4d8543f12 [eslint config] [react] [breaking] enable jsx-a11y rules:
- `jsx-a11y/heading-has-content`
 - `jsx-a11y/html-has-lang`
 - `jsx-a11y/lang`
 - `jsx-a11y/no-marquee`
 - `jsx-a11y/scope`
 - `jsx-a11y/href-no-hash`
 - `jsx-a11y/label-has-for`
2016-07-05 13:38:57 -07:00
Jordan Harband
a6da4bb5b2 [eslint config] [react] [breaking] enable aria rules:
- `jsx-a11y/aria-props`
 - `jsx-a11y/aria-proptypes`
 - `jsx-a11y/aria-unsupported-elements`
 - `jsx-a11y/role-has-required-aria-props`
 - `jsx-a11y/role-supports-aria-props`
2016-07-05 13:36:21 -07:00
Jordan Harband
6857f7af97 [eslint config] [react] [breaking] enable react rules:
- `react/jsx-filename-extension`
 - `react/jsx-no-comment-textnodes`
 - `react/jsx-no-target-blank`
 - `react/require-extension`
 - `react/no-render-return-value`
 - `react/no-find-dom-node`
 - `react/no-deprecated`
2016-07-05 13:20:39 -07:00
Jordan Harband
cb36ed90c3 [eslint config] [deps] [breaking] update eslint to v3, eslint-config-airbnb-base to v5, eslint-find-rules, eslint-plugin-import, eslint-plugin-jsx-a11y to v2, eslint-plugin-react to v6, tape.
- drop node < 4 support
2016-07-05 13:15:51 -07:00
Zane Mountcastle
75c961a43f Change 'Brazilian' to 'Portuguese' 2016-08-01 10:41:15 +08:00
Jordan Harband
a533e2dd35 [eslint config] [base] v5.0.1 2016-07-29 17:32:24 -07:00
Jordan Harband
4425d3c76b [eslint config] [base] [deps] update eslint to v3.2 2016-07-29 16:29:00 -07:00
Jordan Harband
49dfcc42de [eslint config] [*] improve prepublish script 2016-07-29 16:29:50 -07:00
Jordan Harband
b2ea03ef2c [eslint config] [base] [deps] update eslint-plugin-import 2016-07-29 08:14:10 -07:00
Joe Lencioni
4dbb2af7da Improve React HOC example
I decided that `WrappedComponent` is clearer than `Component` here, so I
made the switch. I also realized that `WrappedComponent.name` might
still be undefined, so I added a fallback value of "Component".
2016-07-27 09:54:00 -07:00
Joe Lencioni
1917968acb Add missing closing paren in HOC guideline
As pointed out by eagle-eyed @pepakriz.
2016-07-27 09:53:42 -07:00
James Glover
0165c13845 [eslint config] [*] [docs] Added subshell to usage commands and converted samples to the three backtick markdown syntax with language specifier for highlighting. 2016-07-27 20:18:11 +10:00
Joe Lencioni
4c8f78921f Add guideline for displayName in higher-order components
This guideline will help us keep our higher-order components consistent
and easy to understand.

Fixes #968.
2016-07-26 16:51:08 -07:00
Jordan Harband
eea5f0f5f5 [eslint config] [base] no-unused-expressions: flesh out options
Fixes #963.
2016-07-25 12:39:31 -07:00
Jordan Harband
1fb300c6c7 [eslint config] [base] v5.0.0 2016-07-24 09:55:44 -07:00
Jordan Harband
616233c8b2 [eslint config] [base] [breaking] enable no-unexpected-multiline rule 2016-07-24 09:51:50 -07:00
Jordan Harband
bbfb9600dc [eslint config] [*] [deps] update babel-tape-runner, add babel-preset-airbnb 2016-07-23 21:28:04 -07:00
Joe Lencioni
da3eb59b39 Merge pull request #961 from idugcoal/master
Change 'conjunctions' to 'contractions'
2016-07-23 12:55:46 -07:00
Doug Cole
892128366a change 'conjunctions' to 'contractions' 2016-07-23 11:53:45 -07:00
Jordan Harband
9d598c3563 [eslint config] [base] [breaking] enable more overlooked rules:
- `no-void`
 - `constructor-super`
 - `prefer-spread`
 - `no-new-require`
 - `no-undef-init`
2016-07-22 15:40:00 -07:00
Jordan Harband
4921e03a7b [eslint config] [base] [breaking] enable import/newline-after-import
Per https://github.com/benmosher/eslint-plugin-import/issues/386 / https://github.com/benmosher/eslint-plugin-import/issues/441
2016-07-14 21:27:37 -07:00
Jordan Harband
df8627d72f [eslint config] [*] [tests] fix prepublish scripts. 2016-07-19 13:57:42 -07:00
Jordan Harband
3594ee94ac [eslint config] [*] [docs] forgot “—save-dev” in 623dc44bb9 2016-07-19 10:33:29 -07:00
Jordan Harband
623dc44bb9 [eslint config] [*] [docs] update the peer dep install command to dynamically look up the right version numbers when installing peer deps.
Fixes #956.

This command would be simpler if https://github.com/npm/npm/issues/11213 is ever implemented.
2016-07-19 10:31:40 -07:00
Jordan Harband
ca9c322790 [eslint config] [base] [breaking] enable overlooked rules:
- `linebreak-style`
 - `new-parens`
 - `no-continue`
 - `no-lonely-if`
 - `operator-assignment`
 - `space-unary-ops`
 - `dot-location`
 - `no-extra-boolean-cast`
 - `no-this-before-super`
 - `require-yield`
 - `no-path-concat`
 - `no-label-var`
2016-07-14 22:00:07 -07:00
Jordan Harband
762177eb3b [eslint config] [base] [deps] update eslint, eslint-find-rules, eslint-plugin-import 2016-07-18 14:27:26 -07:00
Jordan Harband
2504e0f85c [eslint config] [base] Fleshing out defaults. 2016-07-14 21:40:05 -07:00
Jordan Harband
385fc9effe Merge pull request #955 from ronal2do/master
Airbnb React/JSX Style Guide translation for PT-BR
2016-07-18 14:47:38 -07:00
Your NameRonaldo
723e12a87d Airbnb React/JSX Style Guide translation for PT-BR 2016-07-18 18:20:32 -03:00
Your NameRonaldo
97da7b65c6 Airbnb React/JSX Style Guide translation for PT-br 2016-07-18 18:17:59 -03:00
Kenny Tran
abcc0c681e Capitalize all comments in react.js 2016-07-15 11:14:22 -07:00
Jordan Harband
325f8ba72f [eslint config] [base] v4.0.2 2016-07-14 22:33:27 -07:00
Jordan Harband
6039804cc3 [eslint config] [base] [fix] repair accidental comma-dangle change. 2016-07-14 22:28:38 -07:00
Jordan Harband
af594687be [eslint config] [base] v4.0.1 2016-07-14 21:36:31 -07:00
Jordan Harband
5f02a6f98f [eslint config] [base] [deps] update eslint-plugin-import 2016-07-14 21:36:07 -07:00
Jordan Harband
b352ec6a4a [eslint config] [base] [fix] Prevent trailing commas in the legacy config.
Fixes #950.
2016-07-11 23:37:51 -07:00
Jordan Harband
a9bfee01cd [guide] Add link to eol-last rule.
Fixes #945.
2016-07-09 09:10:50 -07:00
Luke Libraro
3ad2404974 Added link to Mozilla documentation on Function.bind 2016-07-07 15:46:40 -05:00
Cédric Malard
7fb8b03714 Document for-in restricted usage
https://github.com/airbnb/javascript/issues/851#issuecomment-213834028
2016-07-06 17:00:42 +02:00
Joe Lencioni
7816731d4d Allow importing devDependencies in tests
This rule seems to be giving me errors for some places we have imported
devDependencies in our tests such as tape and eslint. This is actually
okay, so we just need to configure this rule to allow devDependencies
for tests.

While I was at it, I added some whitespace to improve readability and
reduce the likelihood of merge conflicts.
2016-07-05 10:11:18 -07:00
Jordan Harband
6db1af173c [eslint config] [*] [Tests] stop testing < node 4. 2016-07-05 13:07:41 -07:00
Jordan Harband
339861022e [eslint config] [base] v4.0.0 2016-07-02 08:56:05 -07:00
Jordan Harband
b3a02ae982 [eslint config] [breaking] [base] update eslint to v3
- drop support for node 4.
2016-07-02 08:54:05 -07:00
Joe Lencioni
d282e059b1 Add import/no-restricted-paths to imports rules
This rule was added by 1.10.0. I am setting it to be disabled because it
is very project-specific, so it doesn't make sense to enable it here.

https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md

I found the sections of this file a little confusing, so I didn't know
where to put it. I think it would be better to simply alphabetize the
rules but I'll leave that for another time.
2016-07-05 10:04:28 -07:00
Jordan Harband
82629f126d [eslint config] [base] [Deps] update eslint-plugin-import, tape, eslint-find-rules 2016-07-02 08:53:21 -07:00
Jordan Harband
b45fdcd60f [eslint config] [base] add some import plugin settings 2016-07-05 10:35:40 -07:00
Jordan Harband
1f87054e4b [eslint config] [base] [patch] newline-per-chained-call: bump the limit to 4.
Specifically, this is to allow this frequent pattern:
```js
$.ajax({
  …
}).done(() => {
  …
}).fail(() => {
  …
}).always(() => {
  …
});
```
2016-07-05 10:35:40 -07:00
Jordan Harband
9028379f87 [eslint config] [base] [breaking] re-disable import/extensions rule
ref https://github.com/benmosher/eslint-plugin-import/issues/390
2016-07-05 10:35:40 -07:00
Cédric Malard
c9bcc7ef36 Remove leading underscores for private properties
- It follows [ES6 styleguide](https://github.com/airbnb/javascript#naming--leading-underscore)
- eslint plugin is configured this way : `'no-underscore-dangle': [2, { allowAfterThis: false }],`
2016-07-05 18:30:44 +02:00
Jordan Harband
17b773e613 Merge pull request #902 from KevinGrandon/no_string_refs
[eslint config] [react] [breaking] Prevent using string refs.
2016-06-28 10:43:42 -07:00
Kevin Grandon
36d1561596 Prevent using string refs.
According to the official React documentation string refs are considered legacy and will be deprecated in the future.
2016-06-28 10:13:36 -07:00
Shreevatsa
34a9f076df Minor typo: "coxcomb graph" v/s "coxcomb chart"
The "bad" and "good" diffs in section 19.2 had different text; making them the same to avoid confusion about what the difference is.
2016-06-23 10:58:12 -07:00
Jordan Harband
28a04a3a45 [docs] Clear up “confusing arrows” example.
Closes #856.
2016-06-21 22:41:03 -07:00
Jordan Harband
a597da56ca [eslint config] [base] [breaking] enable rest-spread-spacing rule 2016-06-20 17:59:03 -07:00
Jordan Harband
d0973e8e36 [eslint config] [base] add TODO for object-curly-newline.
ref https://github.com/eslint/eslint/issues/6488
2016-06-20 17:58:36 -07:00
Jordan Harband
622a3bc1ab [eslint config] [base] [breaking] re-disable newline-after-import
Per https://github.com/benmosher/eslint-plugin-import/issues/386
2016-06-20 16:11:24 -07:00
Jordan Harband
51f9b0450c [eslint config] [base] [breaking] enable import rules: newline-after-import, prefer-default-export 2016-06-20 15:53:26 -07:00
Jordan Harband
ee2cb41ec4 [eslint config] [base] [breaking] enable no-mixed-operators rule.
Specifically, this is to require parens to avoid cognitive overhead about precedence.
2016-06-20 15:52:05 -07:00
Jordan Harband
6980cce17f [eslint config] [base] [breaking] enable import rules:
- `no-named-as-default`
 - `no-named-as-default-member`
 - `no-extraneous-dependencies`
 - `extensions`
2016-06-20 14:32:19 -07:00
Jordan Harband
5651e607f3 [eslint config] [base] [breaking] enable object-property-newline rule 2016-06-20 14:31:26 -07:00
Jordan Harband
001efc722c [eslint config] [base] update eslint 2016-06-20 13:34:03 -07:00
Michael Clawar
04138345ad Update README.md 2016-06-19 15:47:02 -04:00
Anton Backer
343dc2c34a Remove parens around single argument in React example
Parens around a single argument aren't in line with the js guide:

    If your function takes a single argument and doesn’t use braces,
    omit the parentheses.

0814be638f/README.md (arrows--one-arg-parens)

Another rule violation:

    Wrap JSX tags in parentheses when they span more than one line.

0814be638f/react/README.md (parentheses)
2016-06-17 17:33:49 -07:00
Jordan Harband
0afde8f136 [eslint config] [base] [deps] update eslint 2016-06-17 16:03:03 -07:00
Jordan Harband
0814be638f [eslint config] [base] [deps] update eslint, eslint-find-rules
Adds disabled rules: `max-lines`, `no-mixed-operators`, `rest-spread-spacing`, `object-curly-newline`
2016-06-16 22:44:35 -07:00
hunyong-song
22f59b6e1b Adding link korean translation 2016-06-16 10:20:03 +09:00
Andrzej Duś
defa17e872 Added Syzygy Warsaw 2016-06-15 11:25:19 +02:00
Caleb
90f5a47c33 Updated deprecated Japanese translation link.
old: https://github.com/mitsuruog/javacript-style-guide
new: https://github.com/mitsuruog/javascript-style-guide
2016-06-13 19:15:19 +10:00
Harrison Shoff
b4c49e9ec7 Merge pull request #909 from pietraszekl/patch-1
Adding link to polish translation
2016-06-12 00:16:34 -07:00
Lukasz Pietraszek
29eb575a52 Adding link polish translation 2016-06-11 09:39:03 +01:00
Jordan Harband
f41b4df024 [eslint config] [base] [breaking] enable no-prototype-builtins rule. 2016-06-04 18:14:02 -07:00
Jordan Harband
4700d99864 [eslint config] [base] [breaking] enable no-useless-rename rule 2016-06-04 18:00:02 -07:00
Jordan Harband
d9cb343b51 [eslint config] [base] [breaking] enable unicode-bom rule 2016-06-04 17:58:25 -07:00
Jordan Harband
ab4baf457e [eslint config] [base] [deps] update eslint, eslint-plugin-import 2016-06-04 17:41:41 -07:00
Jordan Harband
89cfa0b81c [eslint config] [*] use in-publish because coffeescript screwed up the prepublish script for everyone 2016-06-04 17:38:41 -07:00
Jordan Harband
eb76edea32 [eslint config] [*] [tests] Only run eslint-find-rules on prepublish, not in tests. 2016-06-04 17:30:00 -07:00
Wesley
3fb9db5a74 fixing broken link
Google moved their style guides to Github (from an SVN server), and this link was broken
2016-06-04 15:17:00 -07:00
Ross Kirsling
267eec57c6 Fix invalid code snippet in 23.2. 2016-06-02 10:24:30 -07:00
Simen Bekkhus
d97d62a2ff Fix react dev dep version 2016-06-01 10:04:07 +02:00
mifi
1db5522888 Fix typo
disallowSpacesInsideObjectBrackets -> requireSpacesInsideObjectBrackets
2016-05-26 22:54:27 +02:00
Alanna Scott
c247fd754b Avoid using an array index as key prop, prefer unique ID 2016-05-25 12:30:34 -07:00
Jordan Harband
4c4210f23d Remove trailing whitespace. 2016-05-25 18:19:19 +02:00
Sergii Tkachenko
199a0a700d Add DoSomething.org to the list of organizations in README 2016-05-25 17:49:40 +03:00
Jason
a8839173cc add chinese simplified for React/JSX style guide 2016-05-25 16:50:37 +08:00
Jordan Harband
b6e4b72fc2 [eslint config] [*] [deps] update eslint, eslint-plugin-jsx-a11y. ensure react is >= 13.0.0 2016-05-21 22:11:20 +02:00
Jordan Harband
429339ee37 [eslint config] [*] fix quoting of rule properties.
Per #885.
2016-05-18 20:00:04 -07:00
Jordan Harband
8e125fa07c [eslint config] [base] [breaking] Enforce proper generator star spacing.
Fixes #887.
2016-05-17 21:27:10 -07:00
Jordan Harband
312cd01a95 [eslint config] [base] quotes: Use object option form rather than deprecated string form.
Per https://github.com/airbnb/javascript/pull/886
2016-05-17 13:50:12 -07:00
Joe Lencioni
43ccc3fe11 Enable imports/imports-first rule
Since imports are hoisted, keeping them all at the top prevents
surprising behavior.
2016-05-17 09:14:48 -07:00
Jordan Harband
e32079d6c4 Merge pull request #881 from akai/re-order-rules
[eslint config] [base] [breaking] Rearrange rules/rule files.
2016-05-16 22:40:38 -05:00
akai
34ccf905d6 [eslint config] [base] [breaking] migrate import's settings/rules to a separate file. 2016-05-17 01:10:00 +08:00
akai
3948eb66d6 [eslint config] [base] [breaking] re-order rules 2016-05-17 00:25:48 +08:00
Jordan Harband
10f4dd88aa [eslint config] [base] [patch] object-shorthand: do not warn when the concise form would have a string literal as a name. 2016-05-15 21:43:40 -05:00
Jordan Harband
7a8083795d [eslint config] [base] [patch] Loosen prefer-const to not warn when the variable is “read” before being assigned to. 2016-05-15 21:42:45 -05:00
Jordan Harband
8d6d227848 [eslint config] [*] [tests] Even though the base config may not be up to date in the main package, let’s npm link the base package into the main one for the sake of travis-ci tests.
(Followup from c7faa91328)
2016-05-15 20:56:54 -05:00
Jordan Harband
638b312b6c [eslint config] [base] update eslint 2016-05-15 21:14:59 -05:00
Joe Lencioni
4ac8aed126 Prepare to enable react-a11y rules
When I first added these, I left TODO notes to come back and evaluate
enabling them. I've gone through and think that we should definitely at
least enable the rules that enforce basic spec compliance (e.g. that
props don't have typos and that all of the required props are provided
for the given role). Since these deal with basic correctness, I don't
think we need to add any verbiage to the style guide for these rules.

We still have some more that we should evaluate and decide about
enabling here, but this is a good step in the right direction.
2016-05-13 11:25:44 -07:00
Jordan Harband
c7faa91328 [eslint config] [tests] Even though the base config may not be up to date in the main package, let’s npm link the base package into the main one for the sake of travis-ci tests. 2016-05-12 17:36:27 -05:00
Jordan Harband
788fb2297a [eslint config] [*] [deps] update eslint-plugin-import 2016-05-12 17:28:57 -05:00
Joe Lencioni
d68a067f2b Prepare to enable import/prefer-default-export
This was recently added to eslint-plugin-export. It enforces that
modules that only have a single export use a default export instead of a
named export. Since this is a breaking change and we want to cluster
breaking changes, I marked it as 0 for now with a TODO to enable when
that time comes.
2016-05-12 15:21:07 -07:00
Joe Lencioni
5acae06653 Add whitespace between rules
I found these rules all smashed together with comments a little
difficult to mentally parse, partly because it is ambiguous which line
the comment applies to. Separating with some whitespace helps a lot
here, and will also reduce the likelihood of merge conflicts in this
code.
2016-05-12 11:43:53 -07:00
Jordan Harband
db732788e7 [eslint config] [react] [patch] loosen jsx-pascal-case rule to allow all caps component names 2016-05-09 15:41:52 -07:00
Jordan Harband
d25a199c56 [eslint config] [deps] update eslint-config-airbnb-base, eslint-plugin-react 2016-05-09 15:40:46 -07:00
Felipe Vargas
b660d4cc3f Add semicolon in arrow functions section 2016-05-08 18:15:41 -04:00
Jordan Harband
03c5a1f955 [eslint config] v9.0.1 2016-05-08 14:57:25 -07:00
Jordan Harband
d95dc3d500 [eslint config] [base] v3.0.1 2016-05-08 14:55:42 -07:00
Jordan Harband
be5c90a417 [docs] Array.from, not Array#from 2016-05-08 14:54:14 -07:00
Jordan Harband
56a524a47e [eslint config] [base] [patch] re-disable no-extra-parens
Fixes #869, #867.
2016-05-08 14:53:24 -07:00
Alejandro Oviedo
ba5d9f0cd7 add links to resources on mdn 2016-05-08 11:33:58 -03:00
Jordan Harband
330169d15e [eslint config] v9.0.0 2016-05-07 10:39:47 -07:00
Jordan Harband
8b396ab9ef [eslint config] [deps] Update eslint-config-airbnb-base, eslint-plugin-jsx-a11y, eslint-plugin-import, eslint-find-rules 2016-05-07 10:33:05 -07:00
Jordan Harband
1b31efc07e [eslint config] [base] v3.0.0 2016-05-06 18:04:54 -07:00
Jordan Harband
92a3d5570b [eslint config] [base] [breaking] enable import/no-mutable-exports 2016-05-06 17:44:59 -07:00
Jordan Harband
36e088759f [eslint config] [base] [patch] enable import/no-duplicates 2016-05-06 17:40:57 -07:00
Jordan Harband
b20cf1966c [eslint config] [base] [minor] enable import/no-amd
(per https://github.com/airbnb/javascript#modules--use-them )
2016-05-06 17:40:20 -07:00
Jordan Harband
83c431d655 [eslint config] [base] [breaking] enable no-class-assign rule, to pair with no-func-assign 2016-05-06 17:39:09 -07:00
Jordan Harband
e9aec9e94f [eslint config] [base] update eslint-plugin-import, eslint-find-rules 2016-05-06 12:24:13 -07:00
Jordan Harband
fd5c71c0a9 [eslint config] [base] [breaking] widen no-extra-parens to include everything, except nestedBinaryExpressions
Per https://github.com/eslint/eslint/issues/3065#event-626005438
2016-05-04 16:52:06 -07:00
Josh Perez
6eec3a6df7 Merge pull request #864 from taion/patch-1
Add 4Catalyzer to users
2016-05-04 16:34:36 -07:00
Jimmy Jia
f9089d075a Add 4Catalyzer to users 2016-05-04 19:31:04 -04:00
Jordan Harband
4540293d44 [eslint config] [*] [dev deps] update eslint-find-rules 2016-05-03 22:16:31 -07:00
Jordan Harband
6c25bcf9c1 [eslint config] [base] [breaking] Re-enabling newline-per-chained-call
Per https://github.com/airbnb/javascript/issues/748#issuecomment-216690840 and https://github.com/eslint/eslint/pull/5365
2016-05-03 22:15:25 -07:00
Jordan Harband
d1f2416ffa [eslint config] [deps] update eslint-config-airbnb-base, eslint, eslint-plugin-import, eslint-plugin-jsx-a11y 2016-04-30 00:06:22 -07:00
Jordan Harband
f806ed6bb3 [Tests] on node v6 2016-04-30 00:05:24 -07:00
Jordan Harband
dc4130cdbc [eslint config] [base] v2.0.0 2016-04-30 00:01:21 -07:00
Jordan Harband
31e8412231 [eslint config] [base] [breaking] enable no-unsafe-finally rule 2016-04-30 00:00:22 -07:00
Jordan Harband
d85abc587a [eslint config] [base] [semver-minor] enable no-useless-computed-key rule 2016-04-30 00:00:01 -07:00
Jordan Harband
56fd094e01 [eslint config] [base] [deps] update eslint, eslint-plugin-import 2016-04-29 23:57:23 -07:00
Filip Spiridonov
c81727accd Remove an extra backtick from the README.md 2016-04-26 20:55:10 -07:00
Jordan Harband
33ff1adb2d [eslint config] [deps] update eslint-config-airbnb-base, eslint-find-rules, eslint-plugin-import, eslint-plugin-jsx-a11y 2016-04-26 01:58:30 -07:00
Jordan Harband
3519daf60d [eslint config] [base] v1.0.4 2016-04-26 02:11:23 -07:00
Jordan Harband
d45349497a [eslint config] [base] [deps] update eslint-find-rules, eslint-plugin-import 2016-04-26 02:06:46 -07:00
Jordan Harband
1e1772b340 [guide] [es5] Update whitespace and missing function names.
Per https://github.com/airbnb/javascript/issues/55#issuecomment-214672292
2016-04-26 02:06:46 -07:00
Kristóf Poduszló
7431ef13a0 Remove React from the readme of eslint-config-airbnb-base 2016-04-25 19:32:09 +02:00
Oliver THEBAULT
a71bffa5e3 Fix README "4.5" bad reduce example 2016-04-24 19:48:45 +02:00
Jimmy Jia
79af88d9d6 Clarify stateless component function naming 2016-04-22 12:13:22 -04:00
Jordan Harband
8f0f2890f2 [eslint config] [base] v1.0.3 2016-04-21 23:42:08 -07:00
Jordan Harband
d1383a7cf8 [eslint config] [base] [semver-patch] Allow empty class/object methods. 2016-04-21 23:41:18 -07:00
Jordan Harband
117196b3d0 [eslint config] v8.0.0 2016-04-21 00:06:26 -07:00
Jordan Harband
44ae49ebcf [eslint config] restore jsx-quotes rule, lost in 52d3401f95
Fixes #846.
2016-04-21 10:11:16 -07:00
alexpausan
2d81a2db4a Started using AirBnB style guide. 2016-04-21 10:23:12 +03:00
Jordan Harband
49c5f3d862 [Tests] allow npm install/npm test in the project root to work in both sub packages. 2016-04-20 23:20:14 -07:00
Jordan Harband
f0b6eea9d6 [eslint config] Make eslint-config-airbnb-base a regular dependency.
Per https://github.com/airbnb/javascript/pull/829#issuecomment-212559831
2016-04-20 17:22:56 -07:00
Jordan Harband
277b08710f [eslint config] [deps] update eslint-plugin-jsx-a11y 2016-04-20 16:35:12 -07:00
Jordan Harband
d0ddba17c3 [eslint config] [base] [dev deps] update eslint-find-rules 2016-04-20 23:12:51 -07:00
Jordan Harband
f1ab4805b6 [eslint config] [deps] update eslint-find-rules, eslint-config-airbnb-base 2016-04-20 11:24:52 -07:00
Jordan Harband
0207503bef [eslint config] [base] v1.0.2 2016-04-20 11:19:53 -07:00
Jordan Harband
3c915dd686 [eslint config] [base] [patch] remove “break” statement from restricted syntax.
Per https://github.com/airbnb/javascript/issues/840#issuecomment-212541010
2016-04-20 11:15:10 -07:00
Oskar Cieslik
897732f6f0 Add arrow function returning object. 2016-04-20 10:39:06 +02:00
Jordan Harband
37e1c3c6c9 [eslint config] [base] v1.0.1 2016-04-19 22:20:40 -07:00
Jordan Harband
d06147d279 [eslint-config] [base] [semver-patch] Allow == null.
Closes #542.
2016-04-19 22:15:39 -07:00
Jordan Harband
2dfd520930 [eslint config] [react] Add guide section on react/jsx-curly-spacing
Per #693.
2016-04-19 20:54:45 -07:00
Jordan Harband
13cddaf51e [eslint config] [breaking] enable react/jsx-curly-spacing rule.
Fixes #693.
2016-04-19 20:17:05 -07:00
Joe Lencioni
02414502b6 Upgrade eslint-plugin-jsx-a11y 0.6.2 -> 1.0.1
This new version renames most of the rules, and adds a number of new
rules that we will need to evaluate. I simply added them for now with
TODO comments so we remember to come back to them and make decisions
about each one. I also alphabetized the list to make it easier to find
what you are looking for.
2016-04-19 17:22:43 -07:00
Victor Brouk
763416260a [guide] fix broken deep link to 'testing--yup' 2016-04-19 15:46:29 -07:00
Jordan Harband
52d3401f95 [eslint config] [eslint config base] [breaking] Migrate non-React rules to a separate linter config. 2016-04-16 11:04:28 -07:00
Jordan Harband
bdbecf23e2 Merge pull request #833 from bae-unidev/master
jshint: 'esnext' option has been deprecated
2016-04-19 00:45:02 -07:00
Simen Bekkhus
8c63dd93a7 Remove false comment 2016-04-19 08:39:16 +02:00
Bae Hyun Seung
bf8677d1ac 'esnext' option has been deprecated 2016-04-19 15:38:41 +09:00
Jordan Harband
e856d93ada [deps] update eslint-plugin-react, eslint-plugin-import 2016-04-18 23:23:55 -07:00
Jordan Harband
a9db06e1dd [eslint config] Add eslint-find-rules to prevent missing rules. 2016-04-17 13:09:21 -07:00
Jordan Harband
12d08b38dc [eslint config] Add missing disabled rules. 2016-04-17 13:05:01 -07:00
Jordan Harband
e1cbcbecf6 [eslint config] [breaking] enable global-require rule 2016-04-17 13:03:16 -07:00
Jordan Harband
6efcda314d [eslint config] [breaking] enable no-restricted-syntax rule.
Forbids “with”, “break”, “debugger”, “for..in”, and labels.
2016-04-17 12:58:55 -07:00
Jordan Harband
140ce8b56c [eslint config] [breaking] disallow empty restructuring patterns 2016-04-17 12:52:23 -07:00
Jordan Harband
3efe10d42e [eslint config] [breaking] disallow empty methods 2016-04-17 12:48:54 -07:00
Jordan Harband
c97bd772b4 [eslint config] [react] separate a11y rules to their own file 2016-04-17 13:22:41 -07:00
Jordan Harband
48ab6d6e76 [eslint config] [react] [semver-minor] enable jsx-indent rule 2016-04-17 13:19:40 -07:00
Jordan Harband
066c3b1a3c [eslint config] [react] [semver-minor] enable jsx-equals-spacing rule 2016-04-17 13:18:39 -07:00
Jordan Harband
970848f1a2 [eslint config] [semver-minor] enforce spacing inside single-line blocks. 2016-04-17 12:45:37 -07:00
Jordan Harband
c86cfaa6f9 [eslint config] [semver-patch] Enable no-useless-concat rule which prefer-template already covers 2016-04-17 12:53:54 -07:00
Jordan Harband
f468a52d82 [eslint config] [tests] remove parallelshell 2016-04-17 13:15:13 -07:00
Jordan Harband
f268237c71 [eslint config] [react] [semver-minor] Add react/jsx-first-prop-new-line rule 2016-04-17 12:30:28 -07:00
Jordan Harband
4ab741190c [eslint config] [react] update eslint-plugin-react 2016-04-17 12:28:18 -07:00
Jordan Harband
c29560441e [eslint config] It doesn’t matter which react version we install since we’re just testing module resolution. 2016-04-16 11:53:21 -07:00
Jordan Harband
cbd2c38da8 [eslint config] [dev deps / peer deps] update eslint 2016-04-16 11:50:21 -07:00
Jordan Harband
81d01645c2 [eslint config] remove need for a local symlink. 2016-04-16 11:05:25 -07:00
Jordan Harband
fc1443b80f [guide] add link on perf of array iteration methods 2016-04-16 09:54:28 -07:00
Jordan Harband
688ef3c2eb [guide] remove AIIFE to avoid CallExpression quirk.
Fixes #828.
2016-04-15 19:24:48 -07:00
Jordan Harband
56e6815a84 [guide] Attempt to clarify filename conventions
Fixes #817.
2016-04-13 22:37:46 -07:00
Joe Lencioni
eb4f7cb3a8 Properly capitalize ECMAScript 2016-04-14 09:06:33 -07:00
Joe Lencioni
531950cc26 Add plugin requirements to config package readme
I missed these when I added some eslint-plugin-import rules.
2016-04-14 09:05:24 -07:00
Jordan Harband
92a66ccc7c [guide] [breaking] Disallow leading underscores - there’s no such thing as “private properties”.
Per https://github.com/airbnb/javascript/issues/490#issuecomment-209126331
2016-04-12 15:27:09 -07:00
Jordan Harband
4af3f9755e Merge pull request #825 from lencioni/eslint-plugin-import
[eslint config] [semver-minor] Enable import/no-unresolved and import/export rules
2016-04-13 17:55:14 -07:00
Joe Lencioni
0fe4f558a6 Enable import/no-unresolved and import/export rules
These come from eslint-plugin-import. We've been using these rules for a
while at Airbnb so it seems like a good time to include them in this
configuration. We've found the no-unresolved rule in particular to be
very helpful when working across a large codebase.

  https://github.com/benmosher/eslint-plugin-import

Since the no-unresolved rule works on commonjs, I decided to include it
in the node configuration as well.

I think there are some more rules from this plugin that are worth
enabling, but this seems like a great place to start.
2016-04-13 17:13:00 -07:00
Joe Lencioni
662519efc0 Link to eslint.org instead of github where possible
In most cases we link to documentation on the eslint.org site instead of
on GitHub. I found a couple of stragglers and decided to make things a
little more consistent.
2016-04-13 14:24:53 -07:00
Jordan Harband
956f91527b [eslint config] [semver-minor] enforce no-underscore-dangle 2016-04-12 15:32:11 -07:00
C. T. Lin
9060fba34a Added eslint-plugin-jsx-a11y to install script 2016-04-12 13:38:25 +08:00
Jordan Harband
bcc5c5d8dd [Tests] run subpackage tests at top level. 2016-04-11 15:30:48 -07:00
Jordan Harband
93b0a10eb7 [eslint config] v7.0.0 2016-04-11 15:24:22 -07:00
Jordan Harband
66ec951087 [eslint config] [peer deps] update eslint-plugin-jsx-a11y 2016-04-11 15:22:26 -07:00
Joe Lencioni
a929776d67 Improve guideline for image alt text
After digging into this rule a little more with @evcohen, we believe that
it is okay for images to have an empty string for alt text and have
updated the plugin to reflect that understanding. This commit bumps our
dependency on the rule to include this fix and updates our guideline to
match.
2016-04-08 18:42:51 -07:00
Brett Sanders
f5d6e9646c [guide] Update eslint rule for keyword-spacing, small fix for consistency 2016-04-07 14:02:11 -07:00
Jordan Harband
7c0bb0a6de [eslint config] [breaking] enable react/require-render-return 2016-04-06 22:57:44 -07:00
Jordan Harband
7b5731157f [eslint config] [semver-minor] enable jsx-pascal-case rule. 2016-04-06 22:52:55 -07:00
Jordan Harband
6fd8fb60b3 [eslint config] [dev deps] update eslint, eslint-plugin-react 2016-04-06 22:51:47 -07:00
Jordan Harband
c5366984b3 Merge pull request #813 from lencioni/jsx-a11y
[eslint config] [react] [breaking] Add accessibility rules to the React style guide + `eslint-plugin-a11y`
2016-04-06 15:04:51 -07:00
Joe Lencioni
3f73e35b18 Use jsx fenced codeblocks for JSX code
GitHub knows how to do JSX syntax highlighting. Since we are using JSX
in this document, I figured we might as well tell GitHub to highlight
the syntax as JSX here. This will lead to a better reading experience.
2016-04-06 14:51:45 -07:00
Joe Lencioni
f697a15e50 Add note and rule about not using accessKey
Inconsistencies between keyboard shortcuts and keyboard commands used by
people using screenreaders and keyboards complicate accessibility.
2016-04-06 14:51:44 -07:00
Joe Lencioni
0c3b13fe93 Add note and rule about valid, non-abstract ARIA roles
This rule will help people use only valid roles, which might save people
from simple, accessibility-busting mistakes.
2016-04-06 14:51:44 -07:00
Joe Lencioni
f2aca29ed9 Add note and rule about redundant alt text
Screenreaders already announce `img` elements as images, so there is no
need to include this information in the alt text. This will give people
using assistive technologies a smoother experience.
2016-04-06 14:51:44 -07:00
Joe Lencioni
acbddc1083 Add note and rule about image alt text
We want our React apps to be accessible. One thing that developers can
do is properly use alt text on images. Thankfully, there is an ESLint
rule that will enforce these things for us.
2016-04-06 14:51:22 -07:00
Kevin Moot
6e770062bb Adding The Nerdery to the "In the Wild" section 2016-04-04 19:07:35 -05:00
Peter Kuiper
a2bdbb83d1 Add KickorStick to 'In the Wild' 2016-04-04 14:20:17 +02:00
Amin
f21412cba9 Broken link to Classes and constructors 2016-04-04 11:39:47 +04:00
Nick
6671a55556 CHORE - Remove Trailing Spaces 2016-04-03 09:59:12 -04:00
Jordan Harband
76e1e4c1de [eslint config] [breaking] Add no-dupe-class-members rule + section.
Closes #785.
2016-04-02 18:08:27 -07:00
Jordan Harband
5b9f081d1d [eslint config] [deps] update eslint, react 2016-04-02 17:46:24 -07:00
Jordan Harband
062929ee5f [eslint config] [breaking] error on debugger statements 2016-04-01 14:25:31 -07:00
Yarun Luon
5ec8765a28 Add Chartboost to 'In the Wild' 2016-03-31 18:17:26 -07:00
Saad Quadri
9415b88afd Add missing description for 7.2 2016-03-30 03:27:55 -04:00
Jordan Harband
81241b83cf [eslint config] [breaking] add no-useless-escape rule. 2016-03-26 23:11:23 -07:00
Jordan Harband
24565121c1 [eslint config] [breaking] add no-duplicate-imports rule. 2016-03-26 22:42:29 -07:00
Jordan Harband
5ce6fb1eae [eslint config] [dev deps] update eslint, eslint-plugin-react 2016-03-26 22:39:17 -07:00
Jordan Harband
ff6e1d0d08 [eslint config] v6.2.0 2016-03-22 23:34:59 -07:00
Juan Scolari
ec898a67e0 Add SysGarage to list of organizations 2016-03-21 20:54:59 -03:00
Gil Birman
94ace27f46 Allow arrow functions in JSX props 2016-03-21 14:53:48 -07:00
Arnav Singh
8db205c4d2 Fix "object destructuring for multiple return values" example
... to use the same destructured properties in the good and bad code.
2016-03-20 22:40:07 -07:00
Jordan Harband
f796cfc81f [peer deps] update eslint, eslint-plugin-react 2016-03-20 17:26:15 -07:00
Jordan Harband
5ded256d3f [Fix] re-enable no-confusing-arrow rule, with allowParens option enabled.
Per #752, fixes #791.
2016-03-20 17:23:49 -07:00
Jordan Harband
9eb24d6b61 [editorial] clean up some constructor examples
Fixes #792
2016-03-16 14:47:35 -07:00
Tim Cheung
6f125a5e85 fix react/prefer-stateless-function link 2016-03-15 15:11:28 +01:00
Jordan Harband
8fe2f9ed52 [eslint config] [dev deps] update eslint, eslint-plugin-react 2016-03-11 16:33:31 -08:00
Tim Daubenschütz
c38cdd2015 Add ascribe's styleguide to the list 2016-03-11 09:29:44 +01:00
Jason Bacchetta
2ff6c427b0 Update README.md
Add parentheses around argument, to be consistent with section 8.4
(include parentheses when using braces).
2016-03-09 19:14:00 -06:00
Jordan Harband
4709e644c0 [guide] Permanent links.
- Preserve the original links, because cool URLs don’t change.
2016-03-08 10:25:31 -08:00
Jordan Harband
9e87e1d13b [guide] add some more justification for one-var and String() type coercions 2016-03-08 10:07:30 -08:00
Jordan Harband
01fc30b65b [Dev Deps] update tape 2016-03-07 14:48:32 -08:00
Jordan Harband
34f64c21e5 Add defaults for react/jsx-no-bind 2016-03-07 14:16:06 -08:00
giang pi
e7f5e0f336 Vietnamese language 2016-03-07 14:01:57 +07:00
Maks Sadowsky
8b6abf8cda Update README: Document corresponding jscs rules 2016-03-06 22:12:14 +02:00
Jordan Harband
0ece94f5bf [eslint config] v6.1.0 2016-03-05 14:43:58 -08:00
Jordan Harband
516297511a Merge remote-tracking branch 'origin/pr/772' 2016-03-05 14:19:42 -08:00
Jordan Harband
7b8a0ca85d [Dev Deps] update eslint-plugin-react
(new rule is in #772)
2016-03-05 14:19:34 -08:00
Jordan Harband
87616367cb [Dev Deps] update eslint, tape, eslint-plugin-react 2016-03-04 20:05:42 -08:00
Jon Tejada
762b7510ab fixed a broken link to REI's JS style guide 2016-03-03 15:21:53 -08:00
David Petersen
03d0054a46 Enable react/prefer-stateless-function rule 2016-03-02 09:19:16 -06:00
Marc-Antoine Duhaime
32e3e0f45a Update README.md
Add colon to TODO and FIXME.
2016-03-02 09:42:02 -05:00
Hyeonsu Lee
246cde0de8 Fix the typo error in JSHint link 2016-03-02 10:25:02 +09:00
chief10
607ad012ee change wording for 8.2 for consistency 2016-03-01 15:28:10 -06:00
Boris Besemer
7684892951 fixes tiny typo's on JSCS rules 2016-02-25 09:12:52 +01:00
Nick Hwang
d321f68c46 Fix word spacing and preserve consistent quotes 2016-02-24 13:55:13 -05:00
Jordan Harband
b32122d5ad Merge pull request #762 from jahvi/patch-2
[eslint config] [semver-minor] Enforce literal syntax for array creation, to match guide
2016-02-24 08:55:39 -08:00
Javier Villanueva
2d8409c3e5 Enforce literal syntax for array creation 2016-02-24 11:03:46 +00:00
David Bows
30c448d1df Updated "In The Wild" to include Brainshark. 2016-02-23 12:54:20 -08:00
Max Beier
cba519a442 Updated CHANGELOG.md 2016-02-23 15:11:31 +01:00
Felix Sanz
714f71d1d2 Added getter/setter info
I tried to search for getter/setter in the readme but nothing was found. Added some info to make a clear statement about them
2016-02-23 01:25:02 +01:00
NakShi
db8b07f51a Fixed README typo 2016-02-22 15:39:53 -08:00
Jordan Harband
6c637b97d9 [eslint config] v6.0.2 2016-02-22 14:49:34 -08:00
Jordan Harband
33f1ddb4c5 Disable no-confusing-arrow until eslint’s bug is resolved.
bug: https://github.com/eslint/eslint/issues/5332

Closes #752.
2016-02-22 14:30:23 -08:00
Jordan Harband
f12b2a195a [Dev Deps] update babel-tape-runner.
Closes https://github.com/wavded/babel-tape-runner/issues/11
2016-02-22 10:46:03 -08:00
Cihan Bebek
50ff33de88 Small typo fix in 18.6 'bad'-example.
Function call 'class()' to 'classed()'.
2016-02-21 21:38:33 +02:00
Jordan Harband
f4e94ade2b v6.0.1 2016-02-21 10:59:44 -08:00
Jordan Harband
12fb48611a Disable newline-per-chained-call until eslint’s bug is resolved.
bug: https://github.com/eslint/eslint/issues/5289

Closes #748.
2016-02-21 10:57:42 -08:00
Jordan Harband
8a6f00968d Fix no-useless-constructor example.
Per https://github.com/airbnb/javascript/pull/730#discussion_r53565774
2016-02-21 10:28:54 -08:00
Jordan Harband
b648de3233 [eslint config] v6.0.0 2016-02-21 00:51:00 -08:00
Jordan Harband
07e3cdeadf [eslint config] Update to eslint v2: Merge remote-tracking branch 'origin/harry-eslint-v2'
Closes #730.
2016-02-21 00:50:40 -08:00
Sergey Fursov
4574659833 rearrange comma-dangle rule to match es5/es6 codestyles, fixes #741 2016-02-21 01:31:20 +03:00
Harrison Shoff
0f32b96c12 [changelog] update changelog for 6.0.0 2016-02-20 13:24:55 -08:00
Harrison Shoff
3983d380ed [eslint-v2][arrays] fix example 2016-02-20 23:39:29 -08:00
Harrison Shoff
b79e951280 [eslint-v2][arrays] update array-callback-return good/bad ex 2016-02-20 23:33:39 -08:00
Harrison Shoff
822c0dfdfe [eslint-v2][react] jsx-sort-prop-types => sort-prop-types 2016-02-20 13:10:42 -08:00
Harrison Shoff
07948531dc [eslint-v2][react] set ignoreTranspilerName to false 2016-02-20 13:05:49 -08:00
Harrison Shoff
133fc51e21 [eslint-v2][react] add static-methods to top of sort-comp order 2016-02-20 13:02:15 -08:00
Harrison Shoff
ff0adbe291 [eslint-v2][react] acceptTranspilerName => ignoreTranspilerName 2016-02-20 12:59:00 -08:00
Harrison Shoff
e0959d0f1d [eslint-v2] fix rule links in readme 2016-02-14 19:04:12 -08:00
Harrison Shoff
65609373bf [eslint-v2][template strings] add template-curly-spacing rule, fix #716 2016-02-14 18:56:49 -08:00
Harrison Shoff
1f12a12be4 [eslint-v2] fix empty constructor example 2016-02-14 18:48:31 -08:00
Harrison Shoff
e1a087fbb1 [eslint-v2] add prefer-rest-params 2016-02-14 18:45:44 -08:00
Harrison Shoff
c5b4f05879 [eslint-v2] add one-var-declaration-per-line 2016-02-14 18:39:32 -08:00
Harrison Shoff
e6cbcf4cc5 [eslint-v2][whitespace] add no-whitespace-before-property rule 2016-02-14 18:35:23 -08:00
Harrison Shoff
92df6357b3 [eslint-v2][variables] add no-self-assign 2016-02-14 18:30:28 -08:00
Harrison Shoff
3762c9add8 [eslint-v2] add no-new-symbol rule 2016-02-14 14:58:28 -08:00
Harrison Shoff
ba10353e9b [eslint-v2][arrow functions] improve examples 2016-02-14 14:50:49 -08:00
Harrison Shoff
6a03a32915 [eslint-v2][arrow functions] add no-confusing-arrow rule 2016-02-14 14:47:23 -08:00
Harrison Shoff
172dffbb52 [eslint-v2][whitespace] add newline-per-chained-call rule 2016-02-14 11:48:04 -08:00
Harrison Shoff
fbd9c35dd3 [eslint-v2][arrays] add array-callback-return rule 2016-02-14 11:14:38 -08:00
Harrison Shoff
a126d0b85c [eslint-v2] enforce yield-start-spacing, no-unused-labels, no-extra-label 2016-02-14 12:56:03 -08:00
Harrison Shoff
c05b2da9db [eslint-v2] add new rules, disabled:
- `id-blacklist`
 - `no-extra-label`
 - `no-implicit-globals`
 - `no-restricted-imports`
 - `no-unmodified-loop-condition`
 - `no-unused-labels`
 - `sort-imports`
 - `yield-star-spacing`
2016-02-14 02:50:51 -08:00
Harrison Shoff
91b83650b0 [eslint-v2][constructors] fix bad + good examples 2016-02-14 02:34:47 -08:00
Harrison Shoff
1cbc628c49 [eslint-v2][constructors] disallow unnecessary constructors 2016-02-13 13:57:38 -08:00
Harrison Shoff
5109c84926 [eslint-v2] fix no-labels rule 2016-02-13 13:41:52 -08:00
Harrison Shoff
75807b9d5e [eslint-v2] no gens, no dup props in obj literal 2016-02-12 11:42:15 -08:00
Harrison Shoff
aa9add108e [pkg] add harry to contributors 2016-02-12 11:37:39 -08:00
Jordan Harband
8b58d8770c v5.0.1 2016-02-13 11:11:39 -08:00
Jordan Harband
d952efed24 [Fix] eslint peerDep should not include breaking changes. 2016-02-13 11:10:48 -08:00
Harrison Shoff
3aa8c58487 [eslint-v2] fix keyword-spacing style and sorting 2016-02-12 11:36:26 -08:00
Harrison Shoff
4f32315b24 [eslint-v2] ecmaFeatures => parserOptions 2016-02-12 11:36:08 -08:00
Harrison Shoff
dff5099238 [eslint-v2] set es6 env to true 2016-02-12 11:30:11 -08:00
Harrison Shoff
da4213c6dd [eslint-v2] fix no-labels rule 2016-02-12 11:29:20 -08:00
Harrison Shoff
1efb11ca93 [eslint-v2] space-after/before/return/throw/case => keyword-spacing 2016-02-12 11:11:22 -08:00
Harrison Shoff
d49a1ed670 [eslint-v2] no-empty-label => no-labels 2016-02-12 11:10:30 -08:00
Harrison Shoff
1bb72ab9e2 [Deps] update eslint to v2, eslint-plugin-react to v4 2016-02-12 11:09:39 -08:00
Jordan Harband
44cc90f31c Merge pull request #715 from lencioni/sort-comp-statics
[guide] [react] Sort static methods above constructor
2016-02-04 15:26:39 -08:00
Joe Lencioni
e007ec5be9 Sort static methods above constructor for React
I think it makes more sense to put static methods above the constructor
in classes. I would like to update the ESLint configuration to match
this, but it looks like the react/sort-comp rule does not support it
quite yet.

  https://github.com/yannickcr/eslint-plugin-react/issues/128
2016-02-04 11:01:17 -08:00
Ray Sinlao
24e7fd0c14 Added parenthesis to 'good' example in 8.2 2016-02-04 00:00:58 -08:00
Jordan Harband
06fab80dfa v5.0.0 2016-02-03 18:29:18 -08:00
Jordan Harband
a8461e0453 [eslint config] [fix] fix npm run lint 2016-02-03 18:28:07 -08:00
Jordan Harband
6f1d92851c [eslint config] [fix] s/no-case-declaration/no-case-declarations/g (from #712) 2016-02-03 18:27:59 -08:00
Jordan Harband
b6920af581 [eslint config] [dev deps] update eslint-plugin-react, react, tape 2016-02-03 17:26:33 -08:00
Jordan Harband
7e15ccf4cb [eslint config] [breaking] disallow unneeded ternary expressions. 2016-02-03 17:25:00 -08:00
Jordan Harband
fa4925be82 Merge pull request #712 from lencioni/no-case-declarations
[eslint config] [breaking] Avoid lexical declarations in case/default clauses
2016-02-03 13:04:51 -08:00
Joe Lencioni
4d74fe1f5a Add example of a case clause that does not need a block
As @kesne and @ljharb pointed out, this section was unclear about
whether or not you should always include blocks for all case clauses. To
make things clearer, I am adding a case clause that does not need a
block to the good example.

We decided that we should only require blocks for case clauses that
actually need them because it matches the as-needed spirit of section
3.8 ("Only quote properties that are invalid identifiers"). Perhaps if
there was an as-needed but consistent setting for the ESLint rule, we
would consider revising this a little, but this seems good enough for
now.
2016-02-03 12:23:51 -08:00
Joe Lencioni
38d9b34b27 Avoid lexical declarations in case/default clauses
This commit adds guidance warning people to avoid lexical declarations
in case/default clauses and enables the corresponding ESLint rule.

  http://eslint.org/docs/rules/no-case-declarations.html

We didn't have a section on switch statements yet, so I thought about
starting one. It seemed like it would best fit between section 15
(Comparison Operators & Equality) and section 16 (Blocks), but I didn't
want to mess up all of the following numberings, since people probably
have references to them. I considered adding this near the end to
minimize this effect, but it really seemed to belong near these other
things. I landed on appending it to Section 15 (Comparison Operators &
Equality) and I think it sorta fits there since switch statements are a
related concept.
2016-02-02 16:11:53 -08:00
Jordan Harband
206e13b185 [guide] remove trailing whitespace 2016-02-02 10:33:18 -08:00
Barry Gitarts
d293e74872 add section 15.5 - Ternaries
add link to the relevant eslint rule
2016-02-02 13:11:55 -05:00
Prayag Verma
7eb7b78513 Minor typo
Remove extra dot
2016-01-30 10:42:33 +05:30
Mark Sanghoon Kim
51510a43c8 Fixed capitalization and comment spacing
Fixed line 1219 to have a lowercase 'a' to be consistent with the style guide.
Fixed line 1831 to only have one space between the // and the =>
2016-01-27 23:14:53 -08:00
Fredrik Olovsson
784d029980 Edit sample code in 24.1 to follow rule 8.1
Replaced function expression with arrow function notation.
2016-01-27 11:53:57 +01:00
LarryBattle
79a6bfa101 Added names to invalid function declarations 2016-01-26 23:53:51 -06:00
Ethan Rubio
760e50704c Fixed capitalization
Fixed capitalization of ES6 to match the rest of the README.
2016-01-26 15:09:05 -08:00
Jordan Harband
da1d031ff8 [guide] [react] add a note preferring normal functions for functional stateless components. 2016-01-26 15:03:13 -08:00
Matt Brennan
94776c35eb Remove language interpretable as an ableist slur 2016-01-26 14:20:55 +00:00
Harrison Shoff
2a7e19a191 Merge pull request #695 from airbnb/move-rules
[rule links] reduce visual clutter
2016-01-25 22:40:20 -08:00
Harrison Shoff
7293a0f02d [rule links] add labels back 2016-01-25 22:34:39 -08:00
Harrison Shoff
992a9cea58 [react][rule links] add eslint labels back 2016-01-25 22:23:16 -08:00
Harrison Shoff
d852f5190e [react][rule links] condense lines 2016-01-25 22:19:01 -08:00
Harrison Shoff
2c06d87d86 [rule links] reduce visual clutter 2016-01-25 21:46:23 -08:00
Daniel Russell
02e1b4e395 Fixed capitalization
Bitshift changed to bitshift
2016-01-24 20:52:24 -08:00
Jordan Harband
c25dbac620 v4.0.0 2016-01-22 16:27:43 -08:00
Harrison Shoff
0839881fd2 Merge pull request #679 from jshen212/patch-1
Fix case type on line 3 comment
2016-01-22 09:52:14 -08:00
David Sorrentino
2c9833fbc2 add WeBox Studio to the organizations list 2016-01-22 11:45:56 +01:00
Rick Yeh
fb3c4cac20 Fixed minor capitalization change in Hoisting
Not sure if it's an actual fix, but just noticed this was the only comment that had capitalization that wasn't a proper noun
2016-01-21 22:54:27 -08:00
Jordan Harband
06746fa39d Merge pull request #688 from joaomilho/patch-2
[guide] Favor stateless functions over classes when there's no state
2016-01-21 13:17:47 -08:00
Brett Jurgens
36765e4d88 add avant to users 2016-01-20 15:13:31 -06:00
Juan Lulkin
4d2578cc83 Fix PR comments
- Space between function name and args;
- use `render(){}` syntax in object literal;
- Fix link to section;
2016-01-20 22:36:11 +02:00
Juan Lulkin
a568c7cf18 Remove space from jsx literal and add space to function definition
According to PR comments.
2016-01-20 19:10:20 +02:00
Juan Lulkin
45834dde1c Favour stateless functions over classes when there's no state 2016-01-20 16:53:59 +02:00
Harrison Shoff
aa6a20e237 Merge pull request #683 from kvzivn/patch-1
fix typo
2016-01-19 18:02:42 -08:00
Jordan Harband
fb65b9ae04 [guide] fix a few IIFE examples 2016-01-19 10:15:36 -08:00
Svein Halvor Halvorsen
018dd6e359 arrow-parens 2016-01-19 13:07:37 +01:00
Jordan Harband
586b7d9dfa [docs] remove trailing whitespace 2016-01-17 18:10:42 -08:00
Kevin Ivan
93a957f4f6 fix typo 2016-01-17 14:55:16 +01:00
Henry Zhu
56ea6c7351 remove specific rule values in text 2016-01-16 22:27:41 -05:00
Henry Zhu
2bd22f0475 Document corresponding jscs rules 2016-01-16 21:46:35 -05:00
Jordan Harband
396e4611c4 [Tests] use parallelshell to parallelize npm run-scripts 2016-01-16 11:02:04 -08:00
Jordan Harband
ab58d3b68e [Tests] run npm run lint as part of tests; fix errors.
hat tip to https://github.com/airbnb/javascript/pull/678#issuecomment-172017623
2016-01-15 10:31:00 -08:00
Prayag Verma
a4845a82cf Update license year range to 2016 2016-01-16 17:33:50 +05:30
Jeff Shen
c778ade841 Fix case type on line 3 comment
Update case type to resemble other comments
2016-01-14 23:30:08 -08:00
Peter Geiss
9498b3f7c4 Clearly show that [] is truthy 2016-01-13 23:12:06 -05:00
Eddie Monge
397f5bbd14 assign variables: give a reason for the assignment
The variable assignment wasn't necessary. This gives a reason to have it there
2016-01-13 14:19:14 -08:00
Simon Olofsson
90e6cd1c98 22.3: Add Link to eslint rule. 2016-01-13 17:45:43 +01:00
Jordan Harband
8e47e39fc5 Merge pull request #677 from simono/patch-3
[eslint config] [minor] Add `prefer-arrow-callback` to ES6 rules (to match the guide)
2016-01-13 08:36:05 -08:00
Simon Olofsson
54b4dea0f9 Add prefer-arrow-callback to ES6 Rules.
This prefers arrow functions as described in https://github.com/airbnb/javascript#8.1
2016-01-13 17:32:30 +01:00
Jordan Harband
44be6af748 Merge pull request #675 from simono/patch-1
[guide] 7.3: Add Link to eslint rule.
2016-01-13 08:26:03 -08:00
Simon Olofsson
59a0bccd92 7.3: Add Link to eslint rule. 2016-01-13 12:25:32 +01:00
Jordan Harband
4ef335e242 [eslint config] [breaking] require outer IIFE wrapping; flesh out guide section.
There was lots of discussion [here](https://github.com/airbnb/javascript/issues/21#issuecomment-10203921), but now that we have both a modern build system and an eslint rule requiring terminating semicolons, the concerns with the “crockford” style no longer apply.
2016-01-10 15:11:05 -08:00
Simon Olofsson
c2fd8fbbd6 Add missing ES6 rules to ESLint config.
`arrow-body-style` (8.2) and `prefer-template` (6.4) are described in
the Style Guide.
2016-01-15 10:46:29 +01:00
Jordan Harband
af81beb6b8 v3.1.0 2016-01-07 22:21:21 -08:00
Jordan Harband
7f62252e7f [guide] clarify function spacing in 18.3
Per #668.
2016-01-07 22:15:46 -08:00
Jordan Harband
ccef92977a Merge pull request #575 from SimenB/patch-1
[eslint config] [minor] Allow multiple stateless components in a single file
2016-01-07 10:24:48 -08:00
Simen Bekkhus
96ef087bdf Allow multiple stateless components in a single file 2016-01-07 19:22:18 +01:00
Jordan Harband
74561b6449 v3.0.2 2016-01-06 17:06:42 -08:00
Josh Perez
e171f8a11d Merge pull request #664 from silvenon/patch-1
Ignore URLs in max-len
2016-01-06 17:03:58 -08:00
Matija Marohnić
8c70a8bc6d Ignore URLs in max-len 2016-01-07 01:11:00 +01:00
Jordan Harband
c4c724c0a3 Merge pull request #663 from silvenon/patch-1
[guide] Link to the eslint rule for radix in parseInt
2016-01-06 15:22:11 -08:00
Matija Marohnić
557b4dacd7 Link to the eslint rule for radix in parseInt 2016-01-07 00:19:06 +01:00
Jordan Harband
ed1f484e1f v3.0.1 2016-01-06 11:24:10 -08:00
Jordan Harband
9af944dd05 [eslint config] [fix] because we use babel, keywords should not be quoted. 2016-01-06 09:06:57 -08:00
Jordan Harband
a260d2042f Merge pull request #658 from foaly-nr1/patch-1
[guide] Fixed typo in URL
2016-01-06 08:27:12 -08:00
Jonny Schmid
6120656fd2 Fixed typo in URL 2016-01-06 11:15:35 +00:00
Jordan Harband
06595a25f7 Merge pull request #657 from mccambridge/master
[guide] clarity in destructuring code example
2016-01-05 14:15:57 -08:00
Sean McCambridge
52047535bd clarity in destructuring code example
readme
2016-01-05 17:11:48 -05:00
Jordan Harband
286e845b53 v3.0.0 2016-01-04 14:33:49 -08:00
Jordan Harband
81c58472b6 Fix a bug introduced in f2afce75e9 / #581 2016-01-04 14:33:49 -08:00
Jordan Harband
77eda9a8e3 Merge pull request #632 from airbnb/ljharb/quote_props
[eslint config] [breaking] enable `quote-props` rule.
2016-01-04 13:36:34 -08:00
Jordan Harband
ccc1fab899 Merge pull request #579 from tomekwi/fix-braces-text
[guide] Bring back note about braces
2016-01-04 11:38:20 -08:00
Tomek Wiszniewski
4ca5764a30 Require parentheses
As suggested by @ljharb in https://github.com/airbnb/javascript/pull/579#issuecomment-166981740
2016-01-04 20:35:42 +01:00
Tomek Wiszniewski
766f3585db Fix typo 2016-01-04 20:35:42 +01:00
Tomek Wiszniewski
b54ce438c8 Clarify 8.4 2016-01-04 20:35:42 +01:00
Tomek Wiszniewski
32ec9dd03a Make 8.2 and 8.4 simpler and more explicit 2016-01-04 20:35:42 +01:00
Tomek Wiszniewski
bc9faf6fec Bring back note about braces 2016-01-04 20:35:42 +01:00
Jordan Harband
619ff1cfd1 Merge pull request #655 from awitherow/master
[guide] missing 's', create(s) under Method
2016-01-04 11:03:18 -08:00
Austin Witherow
fd6867d964 missing 's', create(s) under Method 2016-01-04 16:19:24 +01:00
Jordan Harband
7890b6c5d6 Merge pull request #652 from strburst/link-comma-dangle
[docs] Link newer ESLint rule (no-comma-dangle → comma-dangle)
2016-01-01 09:16:48 -08:00
Allen Zheng
896783d20c Link newer ESLint rule (namely comma-dangle)
The "no-comma-dangle" rule was deprecated in favor or "comma-dangle" in
ESLint v1.0.

See http://eslint.org/docs/rules/no-comma-dangle.html,
http://eslint.org/docs/rules/comma-dangle, and line 4 of
packages/eslint-config-airbnb/rules/errors.js.
2015-12-31 20:23:35 -05:00
Jordan Harband
ceb4195636 Merge pull request #651 from gergoerdosi/max-len
[Fix] fix max-len rule definition for eslint 1.x
2015-12-30 17:45:52 -08:00
Gergo Erdosi
8e54961aeb Fix max-len rule definition
The current definition is valid only in eslint@2.x.x, but this package has a dependency on eslint@1.10.3 which doesn't have all those options yet.
2015-12-31 01:39:07 +01:00
Jordan Harband
6184703f1c Merge pull request #649 from AlicanC/never-mutate-parameters-link
[Docs] Add eslint link for "Never mutate parameters." rule
2015-12-29 15:59:17 -08:00
Alican Çubukçuoğlu
f4b4ff6e1e Add ESLint link for "Never mutate parameters." rule. 2015-12-30 01:54:16 +02:00
Jordan Harband
799085ff41 Merge pull request #647 from AlicanC/cleanup
[Docs] Cleanup markdown indentation
2015-12-29 15:47:26 -08:00
Jordan Harband
d97ed42ee4 Merge pull request #648 from yuyokk/patch-1
[Docs] Add missing back tick
2015-12-29 15:32:39 -08:00
Iurii Kucherov
bbaaf746db Add missing back tick 2015-12-29 22:54:02 +01:00
Alican Çubukçuoğlu
3869c21182 Fix indentation and spacing. 2015-12-29 19:48:16 +02:00
Jordan Harband
aacaca81c8 Merge pull request #643 from AlicanC/split-never-mutate-parameters
[Docs] Make no-param-reassign a separate section.
2015-12-29 09:26:24 -08:00
Alican Çubukçuoğlu
6d9a787ae2 Make reassigning a separate rule. 2015-12-29 19:11:52 +02:00
Jordan Harband
8c241be003 Merge pull request #637 from evenfrost/master
[eslint config] Permit strict mode in "legacy" config
2015-12-24 08:35:26 -08:00
Jordan Harband
6d00939747 Merge pull request #639 from chrisngobanh/max-len
[eslint config] [breaking] Define a max line length of 100 characters
2015-12-24 08:35:04 -08:00
Christopher Banh
e2e4724fbb Address comments in #639
[eslint] Add comment above `max-len` rule with link to its docs
[eslint] Change tab width for `max-len` rule from 4 to 2
[eslint] Replace double quotes around `max-len` with single quotes
[eslint] Use object form of `max-len` and include all of the options
2015-12-24 02:08:16 -08:00
Christopher Banh
f1c249bcd3 Reword section 6.2 to recognize the line length 2015-12-24 02:08:16 -08:00
Christopher Banh
69d3327362 Enable ESLint rule on limiting maxiumum length of line (max-len)
I moved the rule from legacy.js to style.js and enabled it
2015-12-24 02:08:16 -08:00
Christopher Banh
d11f2663c5 Update .jshintrc with new line length 2015-12-24 02:08:16 -08:00
Christopher Banh
b7fbc7b6df Add section 18.12 on line length 2015-12-24 02:08:16 -08:00
Aleksey Kislov
c9a9194243 Preserve strict rule for default export 2015-12-24 11:31:33 +03:00
Jordan Harband
fbf81eba3a Merge pull request #581 from tikotzky/update-eslint-react
[eslint config] [react] add missing rules from eslint-plugin-react (enforcing where necessary)
2015-12-23 18:56:40 -08:00
Mordy Tikotzky
f2afce75e9 add default config to all rules which take a config 2015-12-23 21:39:31 -05:00
Mordy Tikotzky
b294e7cbf2 add missing rules from eslint-plugin-react 2015-12-23 21:38:53 -05:00
Jordan Harband
fcd1c1d9dc Merge pull request #619 from kesne/jgens/react-cleanup
[eslint config] [breaking] [react] Minor cleanup for the React styleguide
2015-12-23 15:04:00 -08:00
Jordan Gensler
e12e5f0480 Removing name prefix rules. 2015-12-23 14:57:22 -08:00
Jordan Gensler
ae69188304 Removing file extensions. Fixing typos. 2015-12-23 14:57:22 -08:00
Jordan Gensler
5c3137d736 Cleaning up the react styleguide. Adding additional info in props. 2015-12-23 14:57:22 -08:00
Jordan Harband
8815205471 Merge pull request #421 from chrisngobanh/jshintrc-fix
Rename jshintrc to .jshintrc
2015-12-23 12:52:54 -08:00
Christopher Banh
8989a8a513 Rename jshintrc to .jshintrc
According to http://jshint.com/docs/, the "special file" to configure JSHint is named `.jshintrc`, not `jshintrc`.
2015-12-23 12:46:03 -08:00
Jordan Harband
75617bd619 Merge pull request #536 from amsardesai/add-version-badge
[eslint config] [Docs] Add version badge
2015-12-23 12:17:27 -08:00
Jordan Harband
4adf9303c2 Merge pull request #576 from evolution-gaming/in-the-wild
[in the wild] Add Evolution Gaming
2015-12-23 12:12:07 -08:00
Jordan Harband
1ac8baa97c Merge pull request #636 from lencioni/react-readme-cleanup
[Docs] React readme cleanup
2015-12-23 11:44:40 -08:00
Joe Lencioni
474087c426 [readme] Use consistent whitespace in react readme
I noticed that some newlines and indentation were a little inconsistent
in this file, so I decided to smooth things out a bit. This should help
people who decide to modify this document in the future. When
determining which is the "right" way to format these things, I decided
to use the style used by base readme as a guide.
2015-12-23 10:12:42 -08:00
Joe Lencioni
a7d3e02a77 [readme] Add missing heading to react TOC
I noticed that this heading wasn't listed in the table of contents.
Adding it will help people see at-a-glance what they might find in this
document.
2015-12-23 10:12:42 -08:00
Joe Lencioni
450e64c9d2 [readme] Add backticks around code items in react readme
I noticed a number of places in this document where code was being
referenced but it was not marked as such. Adding backticks will instruct
the markdown parser to format these bits as code, which should improve
the readability of this document.
2015-12-23 10:12:42 -08:00
Aleksey Kislov
76ff913d26 Permit strict mode
Permit strict mode for legacy configuration as it is not intended to be used with Babel.
2015-12-23 17:34:31 +03:00
Joe Lencioni
055aa14518 [readme] Clean up isMounted section in react readme
When I added this section in f2dc5043a I didn't do a very good job of
following the style used in other parts of this repo. This commit
remedies that.
2015-12-22 22:46:25 -08:00
Jordan Harband
eea8efe551 Merge pull request #635 from lencioni/no-is-mounted
[eslint-config] [breaking] Enable react/no-is-mounted rule
2015-12-22 12:07:04 -08:00
Joe Lencioni
f2dc5043a1 [eslint-config] [minor] Enable react/no-is-mounted rule
isMounted is an anti-pattern [0], is not available when using ES6
classes, and is on its way to being officially deprecated.
eslint-plugin-react recently added the react/no-is-mounted rule in
3.12.0 that prevents its use.

[0]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html

Finishes #633
2015-12-22 12:04:03 -08:00
Jordan Harband
0af35c9883 Merge pull request #634 from lencioni/sort-prefer-es6-class
[eslint config] Sort react/prefer-es6-class alphabetically
2015-12-22 11:47:34 -08:00
Joe Lencioni
6602586a20 [eslint config] [minor] Sort react/prefer-es6-class alphabetically
All of the other rules in this file are in alphabetical order, but this
one was added by c98990c0f out of order at the end. Keeping these in
alphabetical order will help developers find the rules that they are
looking for.
2015-12-22 11:44:28 -08:00
Jordan Harband
4cdc3fe483 [eslint config] [breaking] enable quote-props rule. 2015-12-22 09:49:25 -08:00
Jordan Harband
c98990c0f9 [eslint config] [minor] enable react/prefer-es6-class rule 2015-12-22 09:44:26 -08:00
Jordan Harband
c584319df8 [eslint config] [Dev Deps] update eslint-plugin-react 2015-12-22 09:44:07 -08:00
Jordan Harband
88484cec8d Merge pull request #627 from amplii/no-param-reassign-with-props
[eslint config] [breaking] update best-practices config to prevent parameter object manipulation
2015-12-17 11:25:13 -08:00
Thomas Shafer
a533a4fb93 added newlines after each function 2015-12-17 11:18:36 -08:00
Thomas Shafer
f7971301b0 update examples for style
add link to no-param-reassign rule documentation
2015-12-16 20:21:38 -08:00
Thomas Shafer
2589c67b0c update best-practices config to prevent parameter object manipulation
added good/bad examples of parameter mutation to the readme
2015-12-16 15:43:00 -08:00
Jordan Harband
fcc41eecd7 v2.1.1 2015-12-15 13:07:24 -08:00
Jordan Harband
28476a25d8 [eslint config] add rule link and defaults to jsx-quotes rule 2015-12-15 13:06:28 -08:00
Jordan Harband
09bf5e8301 Merge pull request #622 from billyjanitsch/jsx-quotes
[eslint config] [fix] Remove deprecated react/jsx-quotes
2015-12-15 13:03:16 -08:00
Billy Janitsch
bbcb1371e5 Remove deprecated react/jsx-quotes 2015-12-15 15:59:40 -05:00
Jordan Harband
60b01bdfb9 [eslint config] v2.1.0 2015-12-15 01:22:30 -08:00
Jordan Harband
0fc31eaf1c [eslint config] fix b1500397e1 2015-12-15 01:19:32 -08:00
Jordan Harband
4ab41ede1b [eslint config] [Dev Deps] update eslint 2015-12-14 23:55:21 -08:00
Jake Teton-Landis
a7541c9b22 Merge pull request #582 from jkrems/jk-require-resolve
Use require.resolve to allow nested extend
2015-12-14 23:49:00 -08:00
Jordan Harband
b1500397e1 [eslint config] enable object-shorthand rule.
Fixes #621.
2015-12-14 22:21:52 -08:00
Jordan Harband
28a83da1d1 Merge pull request #620 from OutBoxSoft/master
[Docs] Add OutBoxSoft to the list of organizations
2015-12-14 16:21:02 -08:00
Gerardo Renovales
2ab6253f85 Update README.md
Add OutBoxSoft to the list of organizations
2015-12-14 15:06:57 -05:00
Jordan Harband
5989125d2e Merge pull request #618 from kesne/jgens/react-defaults
[eslint config] [react] [minor] Including missing defaults to the react eslint; enable react/jsx-quotes
2015-12-11 23:17:25 -08:00
Jordan Gensler
d02a506377 Adding links to react rules for quick reference. 2015-12-11 23:13:30 -08:00
Jordan Gensler
e9b1ef92bf Adding links to lint rules in react styleguide. 2015-12-11 23:00:10 -08:00
Jordan Gensler
d5a636f298 [react] Including missing defaults to the react eslint 2015-12-11 18:47:48 -08:00
Jordan Harband
8c76e4f486 Merge pull request #617 from frenzzy/patch-1
[eslint config] [breaking] Require space before/after arrow function's arrow (`arrow-spacing`)
2015-12-11 00:55:22 -08:00
Vladimir Kutepov
514bd87d1a Require space before/after arrow function's arrow (arrow-spacing)
Enable [arrow-spacing](http://eslint.org/docs/rules/arrow-spacing.html) rule, code with space before/after arrow function's arrow is easier to read.
```js
() => {};
(a) => {};
a => a;
() => {'\n'};
()=> {};     /*error Missing space before =>*/
() =>{};     /*error Missing space after =>*/
(a)=> {};    /*error Missing space before =>*/
(a) =>{};    /*error Missing space after =>*/
a =>a;       /*error Missing space after =>*/
a=> a;       /*error Missing space before =>*/
()=> {'\n'}; /*error Missing space before =>*/
() =>{'\n'}; /*error Missing space after =>*/
```
2015-12-11 13:50:46 +05:00
Jordan Harband
802725d366 Merge pull request #615 from winterbe/fix15
Fix syntax highlighting in section 15
2015-12-09 01:58:14 -08:00
Benjamin Winterberg
721b8cd01f Fix syntax highlighting in section 15 2015-12-09 10:51:49 +01:00
Josh Perez
6c89f9587f Merge pull request #608 from airbnb/document-eslint-rules
Documents corresponding eslint rules
2015-12-03 15:47:52 -08:00
Josh Perez
a1efff9f6d Documents corresponding eslint rules 2015-12-03 15:39:49 -08:00
Josh Perez
f0fb395714 Merge pull request #607 from JonAbrams/patch-1
Fix example for section 7.11
2015-12-03 14:41:41 -08:00
Jon Abrams
a31c72a1e5 Fix example for section 7.11
The missing newline caused the markdown parser to misinterpret the beginning and end of the code block.
2015-12-03 14:37:52 -08:00
Jordan Harband
4c0a70e435 [eslint config] v2.0.0
- separate changelog
2015-12-03 13:55:09 -08:00
Jordan Harband
326100a7b9 Merge pull request #605 from airbnb/ljharb/fix_function_spacing
[breaking] Require function spacing: `function <optional name>(`
2015-12-03 13:33:45 -08:00
Jordan Harband
2c3b75d256 Merge pull request #606 from airbnb/ljharb/fix_switch_indent
[breaking] Fix switch statement indentation rule
2015-12-03 13:16:51 -08:00
Jordan Harband
4ccd04b69a I abhor switch statements, but their indentation should be:
```js
switch (foo) {
  case 'bar':
    break;
}
```

not what the plugin currently requires:
```js
switch (foo) {
case: 'bar':
  break;
}
```
2015-12-03 00:09:12 -08:00
Jordan Harband
599ca4f123 Require a space between function and (, and function and the function's name, and disallow spaces between the function's name and (. 2015-12-02 22:58:11 -08:00
Jordan Harband
6e6a2b91e1 Merge pull request #604 from Bisk/master
Add Bisk to the list of organizations
2015-12-02 20:58:08 -08:00
Josh Perez
eee4371299 Merge pull request #600 from zwhitchcox/patch-1
Add facebook's react to "In the Wild"
2015-12-02 13:46:57 -08:00
Gerardo Renovales
e754dcc7cf Update README.md
Adding Bisk to the list of organizations
2015-12-02 16:40:41 -05:00
Jordan Harband
b640c952c1 Merge pull request #602 from kesne/jeopardy
Adding jeopardybot to styleguide users.
2015-12-02 12:26:57 -08:00
Jordan Gensler
2944b9b47b Adding jeopardybot to styleguide users. 2015-12-02 12:24:01 -08:00
zwhitchcox
287dee40e5 Add facebook's react to "In the Wild"
I can't believe you guys didn't have that one! That's probably your best one.
2015-12-02 12:48:46 -05:00
Jordan Harband
33e23fb121 Merge pull request #594 from pigoz/parens-brackets-curlys
Make the spaces within parenthesis/brackes/curlys rules explicit
2015-11-30 15:18:50 -08:00
Stefano Pigozzi
6debbcdd73 Add Section 18.11 - Add spaces inside curly braces
Fixes #593
2015-11-28 18:47:46 +01:00
Stefano Pigozzi
ee3759a7ed Add Section 18.10 - No spaces inside brackets
See #593
2015-11-28 13:29:47 +01:00
Stefano Pigozzi
2557a5bca6 Add Section 18.9 - No spaces inside parentheses
See #593
2015-11-28 13:26:37 +01:00
Jake Teton-Landis
e0326137d4 [eslint config] v1.0.2 2015-11-26 15:30:30 -08:00
Jordan Harband
7476c31246 Merge pull request #592 from ariporad/patch-1
[rules: es6] enable restParams
2015-11-26 00:55:51 -06:00
Ari Porad
e424a249e3 Enable rest params! 2015-11-25 20:48:48 -08:00
Josh Perez
639e3c709a Merge pull request #584 from jonathanp/master
Avoid the word "mutate" while explaining `const`
2015-11-17 11:58:17 -08:00
jpersson
a3495e07f4 Avoid the word "mutate" while explaining const 2015-11-17 13:12:02 -05:00
Jan Krems
c501e0d5a6 Use require.resolve to allow nested extend 2015-11-16 13:40:38 -08:00
Jake Teton-Landis
60480c05ea Merge pull request #578 from adrienverge/enforce-rule-18.5
[eslint] Enforce rule 18.5
2015-11-11 10:57:24 -08:00
Adrien Vergé
09c8589e44 [eslint] Enforce rule 18.5
Rule 18.5 [1] states that files shall end with a single newline
character. Until now, this was not checked because there was no such
option in eslint.

Since version 1.8.0, eslint provides the ability to do that. See pull
request on eslint [2] for details on implementation and usage. Let's use
it in airbnb eslint plugin now!

[1]: https://github.com/airbnb/javascript#18.5
[2]: https://github.com/eslint/eslint/pull/4266
2015-11-11 10:27:04 -08:00
Janis Zarzeckis
96b0057b30 Organisation renamed 2015-11-11 17:48:50 +02:00
Janis Zarzeckis
4c1fbf2bec Add Evolution Gaming to 'In The Wild' section 2015-11-11 14:14:18 +02:00
Jordan Harband
87c9507bb5 Merge pull request #572 from joscha/patch-1
docs: babel-eslint not neede since 1.0.0 any more
2015-11-08 21:36:10 -08:00
Joscha Feth
aa6ca6ff68 docs: babel-eslint not neede since 1.0.0 any more 2015-11-09 14:44:17 +11:00
Jordan Harband
d9b5585be4 [eslint config] v1.0.0 2015-11-08 11:12:17 -08:00
Jordan Harband
c0ef4540e5 Merge pull request #570 from airbnb/ljharb/update_eslint
[eslint config] update `eslint` to require 1.0 or greater
2015-11-06 16:36:21 -08:00
Jordan Harband
d432f58655 Add eslint as a peer dep, 1.0 or greater 2015-11-06 16:32:28 -08:00
Jordan Harband
0b7c979d82 [eslint] Remove babel-eslint dependency. 2015-11-06 15:16:49 -08:00
Jordan Harband
88603b8445 [eslint] update eslint, eslint-plugin-react, react, tape. 2015-11-06 13:09:34 -08:00
Jake Teton-Landis
f4e5967a0a Merge pull request #547 from chrisngobanh/padded-blocks
Prohibit Padded Blocks and Allow Comments in the First Line of a Block
2015-11-05 16:45:47 -08:00
Jake Teton-Landis
7b0ff1246e eslint-config-airbnb 0.1.1 2015-11-05 15:36:01 -08:00
Jake Teton-Landis
c5d3a3434c Merge pull request #569 from airbnb/jake/remove-id-length-rule
[eslint] remove id length rule (too much nutrage)
2015-11-05 15:35:20 -08:00
Jake Teton-Landis
06ed38d57f [eslint] remove id length rule (too much nutrage) 2015-11-05 15:18:59 -08:00
Harrison Shoff
8514f74322 Merge pull request #551 from majapw/patch-1
`export default` should not be inline with the class declaration
2015-11-04 11:17:53 +01:00
Harrison Shoff
a4e5858a35 Merge pull request #566 from airbnb/fix-stray-eval
[6.5] add backticks around stray eval. fixes #556
2015-11-04 11:13:56 +01:00
Harrison Shoff
f130c0ffa2 [6.5] add backticks around stray eval. fixes #556 2015-11-04 11:12:45 +01:00
Harrison Shoff
88d5084009 Merge pull request #564 from frankenbot/master
Update redirects
2015-11-04 11:07:13 +01:00
Jordan Harband
bbeb6a0d38 Merge pull request #562 from airbnb/ljharb/testing
Start to write a realistic "testing" section
2015-11-02 23:33:30 -08:00
frankenbot
49293bbf8c Update redirects 2015-11-02 20:11:56 -08:00
Jordan Harband
f2f8186d0f Start to write a realistic "testing" section 2015-10-31 13:49:53 -07:00
Jordan Harband
2c172bbe3b Merge pull request #561 from adrienverge/issue-539
eslint: Enforce `no-mixed-spaces-and-tabs`
2015-10-30 10:49:53 -07:00
Adrien Vergé
7b834b989c eslint: Fix no-mixed-spaces-and-tabs turn off
Currently the way the rule is defined, mixing spaces and tabulations in
indentation is allowed. However, the comments and documents seems to say
the opposite.

This patchs turns the rule on so mixing spaces and tabs is NOT allowed.

Fixes: #539
2015-10-30 17:00:14 +01:00
Jordan Harband
893ffb34fe Merge pull request #560 from rhbecker/update-eslint-config_no-const-assign
disallow reassignment of `const` variables
2015-10-29 22:48:46 -07:00
RH Becker
b056ad09bb Flag modification of variables that are declared using const keyword as an error. 2015-10-29 22:43:33 -07:00
Jake Teton-Landis
01ba082cf3 Merge pull request #554 from adrienverge/space-before-keywords
eslint: Add missing `space-before-keywords` rule
2015-10-23 09:11:47 -07:00
Adrien Vergé
ab0a6ca92b eslint: Add missing space-before-keywords rule
All examples in README.md seem to agree on avoiding missing whitespaces
before keywords such as:

    if (cond) {
    }else {       // no space before 'else'
    }

    try {
    }catch (e) {  // no space before 'catch'
    }

This patchs adds the `space-before-keywords` rule as an error (as is
`space-after-keywords` already).
2015-10-23 10:57:24 +02:00
Maja Wichrowska
efe7507e65 export default should not be inline with the class declaration
When there are static variables like `propTypes` and `defaultProps`, we shouldn't export them until we have actually set them onto the `Component`. This may change if the current ES7 proposal for static class properties gets accepts, and we update to support it.
2015-10-20 17:31:01 -07:00
Christopher Banh
4b5348a5fc Add examples with if statements to 18.8 2015-10-16 10:35:14 -07:00
Christopher Banh
d276b0c389 Update 17.2 to allow comments in the first line of a block
In #483, justjake said that we should update the style guide to allow
single line comments in the first line of a block.
2015-10-15 18:15:54 -07:00
Christopher Banh
9897e7d8d1 Add Section 18.8 - No padded blocks
This addresses #483
2015-10-15 18:10:25 -07:00
Jake Teton-Landis
89d1e07882 Merge pull request #544 from HubSpot/in-the-wild
Add HubSpot to 'In The Wild' section
2015-10-13 21:31:28 -07:00
Nick Hwang
8dd0b758f3 Add HubSpot to 'In The Wild' section 2015-10-13 23:21:02 -04:00
Josh Perez
8d6a1b40aa Merge pull request #534 from cooperka/react-quote-reasoning
Add reasoning for using double quotes in JSX
2015-10-05 15:41:04 -07:00
Ankit Sardesai
1b46be032e Added version badge to eslint-config-airbnb 2015-10-04 03:15:09 -04:00
Kevin Cooper
ef7fbea3d9 Add further reasoning for using double quotes in JSX 2015-10-01 16:53:49 -07:00
Kevin Cooper
d4f69efeec Add reasoning for using double quotes in JSX 2015-10-01 15:11:17 -07:00
Harrison Shoff
f823047e46 Merge pull request #533 from ecosia/update-inthewild
Add Ecosia to "In the Wild" section.
2015-10-01 10:14:02 -07:00
Gregory McCue
3c3c9a299d Fix link text. 2015-10-01 19:08:05 +02:00
Gregory McCue
be61bbd53c Add Ecosia to "In the Wild" section. 2015-10-01 11:35:30 +02:00
Jordan Harband
98a76908fc Merge pull request #530 from taion/patch-1
Clarify strict ESLint rule
2015-09-29 09:20:35 -07:00
Jimmy Jia
8da7adbdd4 Clarify strict ESLint rule 2015-09-29 12:19:49 -04:00
43 changed files with 3249 additions and 787 deletions

17
.travis.yml Normal file
View File

@@ -0,0 +1,17 @@
language: node_js
node_js:
- "6"
- "5"
- "4"
env:
- 'TEST_DIR=packages/eslint-config-airbnb'
- 'TEST_DIR=packages/eslint-config-airbnb-base'
before_install:
- 'cd $TEST_DIR'
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi'
- 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi'
script:
- 'npm run travis'
sudo: false
matrix:
fast_finish: true

1275
README.md

File diff suppressed because it is too large Load Diff

View File

@@ -267,7 +267,7 @@
```javascript
// anonymous function expression
var anonymous = function() {
var anonymous = function () {
return true;
};
@@ -277,9 +277,9 @@
};
// immediately-invoked function expression (IIFE)
(function() {
(function () {
console.log('Welcome to the Internet. Please follow me.');
})();
}());
```
- Never declare a function in a non-function block (if, while, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears.
@@ -417,7 +417,7 @@
```javascript
// bad
function() {
function () {
test();
console.log('doing stuff..');
@@ -433,7 +433,7 @@
}
// good
function() {
function () {
var name = getName();
test();
@@ -449,7 +449,7 @@
}
// bad - unnecessary function call
function() {
function () {
var name = getName();
if (!arguments.length) {
@@ -462,7 +462,7 @@
}
// good
function() {
function () {
var name;
if (!arguments.length) {
@@ -517,7 +517,7 @@
anonymous(); // => TypeError anonymous is not a function
var anonymous = function() {
var anonymous = function () {
console.log('anonymous function expression');
};
}
@@ -635,10 +635,10 @@
}
// bad
function() { return false; }
function () { return false; }
// good
function() {
function () {
return false;
}
```
@@ -717,7 +717,7 @@
function getType() {
console.log('fetching type...');
// set the default type to 'no type'
var type = this._type || 'no type';
var type = this.type || 'no type';
return type;
}
@@ -727,7 +727,7 @@
console.log('fetching type...');
// set the default type to 'no type'
var type = this._type || 'no type';
var type = this.type || 'no type';
return type;
}
@@ -768,17 +768,17 @@
```javascript
// bad
function() {
function () {
∙∙∙∙var name;
}
// bad
function() {
function () {
∙var name;
}
// good
function() {
function () {
∙∙var name;
}
```
@@ -847,14 +847,14 @@
```javascript
// bad
(function(global) {
(function (global) {
// ...stuff...
})(this);
```
```javascript
// bad
(function(global) {
(function (global) {
// ...stuff...
})(this);↵
@@ -862,7 +862,7 @@
```javascript
// good
(function(global) {
(function (global) {
// ...stuff...
})(this);↵
```
@@ -925,19 +925,19 @@
// bad
var obj = {
foo: function() {
foo: function () {
},
bar: function() {
bar: function () {
}
};
return obj;
// good
var obj = {
foo: function() {
foo: function () {
},
bar: function() {
bar: function () {
}
};
@@ -1020,19 +1020,19 @@
```javascript
// bad
(function() {
(function () {
var name = 'Skywalker'
return name
})()
// good
(function() {
(function () {
var name = 'Skywalker';
return name;
})();
// good (guards against the function becoming an argument when two files with IIFEs are concatenated)
;(function() {
;(function () {
var name = 'Skywalker';
return name;
})();
@@ -1178,50 +1178,60 @@
});
```
- Use a leading underscore `_` when naming private properties.
- Do not use trailing or leading underscores.
> Why? JavaScript does not have the concept of privacy in terms of properties or methods. Although a leading underscore is a common convention to mean “private”, in fact, these properties are fully public, and as such, are part of your public API contract. This convention might lead developers to wrongly think that a change won't count as breaking, or that tests aren't needed. tl;dr: if you want something to be “private”, it must not be observably present.
```javascript
// bad
this.__firstName__ = 'Panda';
this.firstName_ = 'Panda';
this._firstName = 'Panda';
// good
this._firstName = 'Panda';
this.firstName = 'Panda';
```
- When saving a reference to `this` use `_this`.
- Don't save references to this. Use Function#bind.
```javascript
// bad
function() {
function () {
var self = this;
return function() {
return function () {
console.log(self);
};
}
// bad
function() {
function () {
var that = this;
return function() {
return function () {
console.log(that);
};
}
// good
function() {
// bad
function () {
var _this = this;
return function() {
return function () {
console.log(_this);
};
}
// good
function () {
return function () {
console.log(this);
}.bind(this);
}
```
- Name your functions. This is helpful for stack traces.
```javascript
// bad
var log = function(msg) {
var log = function (msg) {
console.log(msg);
};
@@ -1297,11 +1307,11 @@
this.set('lightsaber', lightsaber);
}
Jedi.prototype.set = function(key, val) {
Jedi.prototype.set = function set(key, val) {
this[key] = val;
};
Jedi.prototype.get = function(key) {
Jedi.prototype.get = function get(key) {
return this[key];
};
```
@@ -1343,12 +1353,12 @@
```javascript
// bad
Jedi.prototype.jump = function() {
Jedi.prototype.jump = function jump() {
this.jumping = true;
return true;
};
Jedi.prototype.setHeight = function(height) {
Jedi.prototype.setHeight = function setHeight(height) {
this.height = height;
};
@@ -1357,12 +1367,12 @@
luke.setHeight(20); // => undefined
// good
Jedi.prototype.jump = function() {
Jedi.prototype.jump = function jump() {
this.jumping = true;
return this;
};
Jedi.prototype.setHeight = function(height) {
Jedi.prototype.setHeight = function setHeight(height) {
this.height = height;
return this;
};
@@ -1404,7 +1414,7 @@
...
$(this).on('listingUpdated', function(e, listingId) {
$(this).on('listingUpdated', function (e, listingId) {
// do something with listingId
});
```
@@ -1417,7 +1427,7 @@
...
$(this).on('listingUpdated', function(e, data) {
$(this).on('listingUpdated', function (e, data) {
// do something with data.listingId
});
```
@@ -1435,7 +1445,7 @@
```javascript
// fancyInput/fancyInput.js
!function(global) {
!function (global) {
'use strict';
var previousFancyInput = global.FancyInput;
@@ -1530,7 +1540,7 @@
- **Yup.**
```javascript
function() {
function () {
return true;
}
```
@@ -1562,7 +1572,7 @@
**Tools**
- Code Style Linters
+ [JSHint](http://www.jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/jshintrc)
+ [JSHint](http://www.jshint.com/) - [Airbnb Style .jshintrc](https://github.com/airbnb/javascript/blob/master/linters/.jshintrc)
+ [JSCS](https://github.com/jscs-dev/node-jscs) - [Airbnb Style Preset](https://github.com/jscs-dev/node-jscs/blob/master/presets/airbnb.json)
**Other Style Guides**
@@ -1672,6 +1682,7 @@
- **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript)
- **StudentSphere**: [studentsphere/javascript](https://github.com/studentsphere/javascript)
- **Super**: [SuperJobs/javascript](https://github.com/SuperJobs/javascript)
- **SysGarage**: [sysgarage/javascript-style-guide](https://github.com/sysgarage/javascript-style-guide)
- **Target**: [target/javascript](https://github.com/target/javascript)
- **TheLadders**: [TheLadders/javascript](https://github.com/TheLadders/javascript)
- **T4R Technology**: [T4R-Technology/javascript](https://github.com/T4R-Technology/javascript)

View File

@@ -14,7 +14,7 @@
"node": true,
// Allow ES6.
"esnext": true,
"esversion": 6,
/*
* ENFORCING OPTIONS
@@ -34,8 +34,8 @@
// Prohibit use of a variable before it is defined.
"latedef": true,
// Enforce line length to 80 characters
"maxlen": 80,
// Enforce line length to 100 characters
"maxlen": 100,
// Require capitalized names for constructor functions.
"newcap": true,

View File

@@ -1,11 +0,0 @@
## `.eslintrc`
Our `.eslintrc` requires the following NPM packages:
```
npm install --save-dev \
eslint-config-airbnb \
eslint \
babel-eslint \
eslint-plugin-react
```

View File

@@ -63,7 +63,7 @@
// Warn when variables are defined but never used.
"unused": true,
// Enforce line length to 80 characters
"maxlen": 80,

View File

@@ -3,8 +3,15 @@
"version": "2.0.0",
"description": "A mostly reasonable approach to JavaScript.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"publish-all": "npm publish && cd ./packages/eslint-config-airbnb && npm publish"
"preinstall": "npm run install:config && npm run install:config:base",
"install:config": "cd packages/eslint-config-airbnb && npm prune && npm install",
"install:config:base": "cd packages/eslint-config-airbnb-base && npm prune && npm install",
"test": "npm run --silent test:config && npm run --silent test:config:base",
"test:config": "cd packages/eslint-config-airbnb; npm test",
"test:config:base": "cd packages/eslint-config-airbnb-base; npm test",
"travis": "npm run --silent travis:config && npm run --silent travis:config:base",
"travis:config": "cd packages/eslint-config-airbnb; npm run travis",
"travis:config:base": "cd packages/eslint-config-airbnb-base; npm run travis"
},
"repository": {
"type": "git",

View File

@@ -0,0 +1,3 @@
{
"presets": ["airbnb"]
}

View File

@@ -0,0 +1,8 @@
{
"extends": "./index.js",
"rules": {
// disable requiring trailing commas because it might be nice to revert to
// being JSON at some point, and I don't want to make big changes now.
"comma-dangle": 0
}
}

View File

@@ -0,0 +1,84 @@
5.0.1 / 2016-07-29
==================
- [patch] `no-unused-expressions`: flesh out options
- [deps] update `eslint` to `v3.2`, `eslint-plugin-import` to `v1.12`
- [tests] improve prepublish script
5.0.0 / 2016-07-24
==================
- [breaking] enable `import/newline-after-import`
- [breaking] enable overlooked rules: `linebreak-style`, `new-parens`, `no-continue`, `no-lonely-if`, `operator-assignment`, `space-unary-ops`, `dot-location`, `no-extra-boolean-cast`, `no-this-before-super`, `require-yield`, `no-path-concat`, `no-label-var`, `no-void`, `constructor-super`, `prefer-spread`, `no-new-require`, `no-undef-init`, `no-unexpected-multiline`
- [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-import`, `babel-tape-runner`; add `babel-preset-airbnb`
- [patch] flesh out defaults: `jsx-quotes`
- [docs] update the peer dep install command to dynamically look up the right version numbers when installing peer deps
- [tests] fix prepublish scripts
4.0.2 / 2016-07-14
==================
- [fix] repair accidental comma-dangle change
4.0.1 / 2016-07-14 (unpublished)
==================
- [fix] Prevent trailing commas in the legacy config (#950)
- [deps] update `eslint-plugin-import`
4.0.0 / 2016-07-02
==================
- [breaking] [deps] update `eslint` to v3; drop support for < node 4
- [breaking] enable `rest-spread-spacing` rule
- [breaking] enable `no-mixed-operators` rule
- [breaking] enable `import` rules: `no-named-as-default`, `no-named-as-default-member`, `no-extraneous-dependencies`
- [breaking] enable `object-property-newline` rule
- [breaking] enable `no-prototype-builtins` rule
- [breaking] enable `no-useless-rename` rule
- [breaking] enable `unicode-bom` rule
- [breaking] Enforce proper generator star spacing (#887)
- [breaking] Enable imports/imports-first rule (#882)
- [breaking] re-order rules; put import rules in separate file (#881)
- [patch] `newline-per-chained-call`: bump the limit to 4
- [patch] `object-shorthand`: do not warn when the concise form would have a string literal as a name
- [patch] Loosen `prefer-const` to not warn when the variable is “read” before being assigned to
- [refactor] fix quoting of rule properties (#885)
- [refactor] `quotes`: Use object option form rather than deprecated string form.
- [deps] update `eslint`, `eslint-plugin-import`, `eslint-find-rules`, `tape`
- [tests] Only run `eslint-find-rules` on prepublish, not in tests
3.0.1 / 2016-05-08
==================
- [patch] re-disable `no-extra-parens` (#869, #867)
3.0.0 / 2016-05-07
==================
- [breaking] enable `import/no-mutable-exports`
- [breaking] enable `no-class-assign` rule, to pair with `no-func-assign`
- [breaking] widen `no-extra-parens` to include everything, except `nestedBinaryExpressions`
- [breaking] Re-enabling `newline-per-chained-call` (#748)
- [minor] enable `import/no-amd`
- [patch] enable `import/no-duplicates`
- [deps] update `eslint`, `eslint-plugin-import`, `eslint-find-rules`
2.0.0 / 2016-04-29
==================
- [breaking] enable `no-unsafe-finally` rule
- [semver-minor] enable `no-useless-computed-key` rule
- [deps] update `eslint`, `eslint-plugin-import`
1.0.4 / 2016-04-26
==================
- [deps] update `eslint-find-rules`, `eslint-plugin-import`
1.0.3 / 2016-04-21
==================
- [patch: loosen rules] Allow empty class/object methods
1.0.2 / 2016-04-20
==================
- [patch: loosen rules] Allow `break` (#840)
1.0.1 / 2016-04-19
==================
- [patch: loosen rules] Allow `== null` (#542)
1.0.0 / 2016-04-19
==================
- Initial commmit; moved content over from `eslint-config-airbnb` package.

View File

@@ -0,0 +1,59 @@
# eslint-config-airbnb-base
[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](http://badge.fury.io/js/eslint-config-airbnb-base)
This package provides Airbnb's base JS .eslintrc as an extensible shared config.
## Usage
We export two ESLint configurations for your usage.
### eslint-config-airbnb-base
Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`.
1. Ensure packages are installed with correct version numbers by running:
```sh
(
export PKG=eslint-config-airbnb-base;
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
)
```
Which produces and runs a command like:
```sh
npm install --save-dev eslint-config-airbnb-base eslint@^3.0.1 eslint-plugin-import@^1.10.3
```
2. Add `"extends": "airbnb-base"` to your .eslintrc
### eslint-config-airbnb-base/legacy
Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
1. Ensure packages are installed with correct version numbers by running:
```sh
(
export PKG=eslint-config-airbnb-base;
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
)
```
Which produces and runs a command like:
```sh
npm install --save-dev eslint-config-airbnb-base eslint@^3.0.1 eslint-plugin-import@^1.10.3
```
2. Add `"extends": "airbnb-base/legacy"` to your .eslintrc
See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information.
## Improving this config
Consider adding test cases if you're making complicated rules changes, like anything involving regexes. Perhaps in a distant future, we could use literate programming to structure our README as test cases for our .eslintrc?
You can run tests with `npm test`.
You can make sure this module lints with itself using `npm run lint`.

View File

@@ -0,0 +1,18 @@
module.exports = {
extends: [
'./rules/best-practices',
'./rules/errors',
'./rules/node',
'./rules/style',
'./rules/variables',
'./rules/es6',
'./rules/imports',
].map(require.resolve),
parserOptions: {
ecmaVersion: 7,
sourceType: 'module',
},
rules: {
strict: 2,
}
};

View File

@@ -0,0 +1,21 @@
module.exports = {
extends: [
'./rules/best-practices',
'./rules/errors',
'./rules/node',
'./rules/style',
'./rules/variables'
].map(require.resolve),
env: {
browser: true,
node: true,
amd: false,
mocha: false,
jasmine: false
},
ecmaFeatures: {},
globals: {},
rules: {
'comma-dangle': [2, 'never']
}
};

View File

@@ -0,0 +1,63 @@
{
"name": "eslint-config-airbnb-base",
"version": "5.0.1",
"description": "Airbnb's base JS ESLint config, following our styleguide",
"main": "index.js",
"scripts": {
"lint": "eslint .",
"tests-only": "babel-tape-runner ./test/test-*.js",
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test)",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"travis": "npm run --silent test"
},
"repository": {
"type": "git",
"url": "https://github.com/airbnb/javascript"
},
"keywords": [
"eslint",
"eslintconfig",
"config",
"airbnb",
"javascript",
"styleguide"
],
"author": "Jake Teton-Landis (https://twitter.com/@jitl)",
"contributors": [
{
"name": "Jake Teton-Landis",
"url": "https://twitter.com/jitl"
},
{
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
},
{
"name": "Harrison Shoff",
"url": "https://twitter.com/hshoff"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/airbnb/javascript/issues"
},
"homepage": "https://github.com/airbnb/javascript",
"devDependencies": {
"babel-preset-airbnb": "^2.0.0",
"babel-tape-runner": "^2.0.1",
"eslint": "^3.2.0",
"eslint-find-rules": "^1.11.1",
"eslint-plugin-import": "^1.12.0",
"in-publish": "^2.0.0",
"tape": "^4.6.0"
},
"peerDependencies": {
"eslint": "^3.2.0",
"eslint-plugin-import": "^1.12.0"
},
"engines": {
"node": ">= 4"
}
}

View File

@@ -1,113 +1,235 @@
module.exports = {
'rules': {
// Enforces getter/setter pairs in objects
rules: {
// enforces getter/setter pairs in objects
'accessor-pairs': 0,
// enforces return statements in callbacks of array's methods
// http://eslint.org/docs/rules/array-callback-return
'array-callback-return': 2,
// treat var statements as if they were block scoped
'block-scoped-var': 2,
// specify the maximum cyclomatic complexity allowed in a program
'complexity': [0, 11],
complexity: [0, 11],
// require return statements to either always or never specify values
'consistent-return': 2,
// specify curly brace conventions for all control statements
'curly': [2, 'multi-line'],
curly: [2, 'multi-line'],
// require default case in switch statements
'default-case': 2,
'default-case': [2, { commentPattern: '^no default$' }],
// encourages use of dot notation whenever possible
'dot-notation': [2, { 'allowKeywords': true}],
'dot-notation': [2, { allowKeywords: true }],
// enforces consistent newlines before or after dots
'dot-location': 0,
// http://eslint.org/docs/rules/dot-location
'dot-location': [2, 'property'],
// require the use of === and !==
'eqeqeq': 2,
// http://eslint.org/docs/rules/eqeqeq
eqeqeq: [2, 'allow-null'],
// make sure for-in loops have an if statement
'guard-for-in': 2,
// disallow the use of alert, confirm, and prompt
'no-alert': 1,
// disallow use of arguments.caller or arguments.callee
'no-caller': 2,
// disallow lexical declarations in case/default clauses
// http://eslint.org/docs/rules/no-case-declarations.html
'no-case-declarations': 2,
// disallow division operators explicitly at beginning of regular expression
// http://eslint.org/docs/rules/no-div-regex
'no-div-regex': 0,
// disallow else after a return in an if
'no-else-return': 2,
// disallow use of labels for anything other then loops and switches
'no-empty-label': 2,
// disallow empty functions, except for standalone funcs/arrows
// http://eslint.org/docs/rules/no-empty-function
'no-empty-function': [2, {
allow: [
'arrowFunctions',
'functions',
'methods',
]
}],
// disallow empty destructuring patterns
// http://eslint.org/docs/rules/no-empty-pattern
'no-empty-pattern': 2,
// disallow comparisons to null without a type-checking operator
'no-eq-null': 0,
// disallow use of eval()
'no-eval': 2,
// disallow adding to native types
'no-extend-native': 2,
// disallow unnecessary function binding
'no-extra-bind': 2,
// disallow Unnecessary Labels
// http://eslint.org/docs/rules/no-extra-label
'no-extra-label': 2,
// disallow fallthrough of case statements
'no-fallthrough': 2,
// disallow the use of leading or trailing decimal points in numeric literals
'no-floating-decimal': 2,
// disallow the type conversions with shorter notations
'no-implicit-coercion': 0,
// disallow implicit type conversions
// http://eslint.org/docs/rules/no-implicit-coercion
'no-implicit-coercion': [0, {
boolean: false,
number: true,
string: true,
allow: [],
}],
// disallow var and named functions in global scope
// http://eslint.org/docs/rules/no-implicit-globals
'no-implicit-globals': 0,
// disallow use of eval()-like methods
'no-implied-eval': 2,
// disallow this keywords outside of classes or class-like objects
'no-invalid-this': 0,
// disallow usage of __iterator__ property
'no-iterator': 2,
// disallow use of labeled statements
'no-labels': 2,
// disallow use of labels for anything other then loops and switches
'no-labels': [2, { allowLoop: false, allowSwitch: false }],
// disallow unnecessary nested blocks
'no-lone-blocks': 2,
// disallow creation of functions within loops
'no-loop-func': 2,
// disallow magic numbers
// http://eslint.org/docs/rules/no-magic-numbers
'no-magic-numbers': [0, {
ignore: [],
ignoreArrayIndexes: true,
enforceConst: true,
detectObjects: false,
}],
// disallow use of multiple spaces
'no-multi-spaces': 2,
// disallow use of multiline strings
'no-multi-str': 2,
// disallow reassignments of native objects
'no-native-reassign': 2,
// disallow use of new operator when not part of the assignment or comparison
'no-new': 2,
// disallow use of new operator for Function object
'no-new-func': 2,
// disallows creating new instances of String,Number, and Boolean
// disallows creating new instances of String, Number, and Boolean
'no-new-wrappers': 2,
// disallow use of (old style) octal literals
'no-octal': 2,
// disallow use of octal escape sequences in string literals, such as
// var foo = 'Copyright \251';
'no-octal-escape': 2,
// disallow reassignment of function parameters
'no-param-reassign': 2,
// disallow use of process.env
'no-process-env': 0,
// disallow parameter object manipulation
// rule: http://eslint.org/docs/rules/no-param-reassign.html
'no-param-reassign': [2, { props: true }],
// disallow usage of __proto__ property
'no-proto': 2,
// disallow declaring the same variable more then once
'no-redeclare': 2,
// disallow use of assignment in return statement
'no-return-assign': 2,
// disallow use of `javascript:` urls.
'no-script-url': 2,
// disallow self assignment
// http://eslint.org/docs/rules/no-self-assign
'no-self-assign': 2,
// disallow comparisons where both sides are exactly the same
'no-self-compare': 2,
// disallow use of comma operator
'no-sequences': 2,
// restrict what can be thrown as an exception
'no-throw-literal': 2,
// disallow unmodified conditions of loops
// http://eslint.org/docs/rules/no-unmodified-loop-condition
'no-unmodified-loop-condition': 0,
// disallow usage of expressions in statement position
'no-unused-expressions': 2,
'no-unused-expressions': [2, {
allowShortCircuit: false,
allowTernary: false,
}],
// disallow unused labels
// http://eslint.org/docs/rules/no-unused-labels
'no-unused-labels': 2,
// disallow unnecessary .call() and .apply()
'no-useless-call': 0,
// disallow useless string concatenation
// http://eslint.org/docs/rules/no-useless-concat
'no-useless-concat': 2,
// disallow unnecessary string escaping
// http://eslint.org/docs/rules/no-useless-escape
'no-useless-escape': 2,
// disallow use of void operator
'no-void': 0,
// http://eslint.org/docs/rules/no-void
'no-void': 2,
// disallow usage of configurable warning terms in comments: e.g. todo
'no-warning-comments': [0, { 'terms': ['todo', 'fixme', 'xxx'], 'location': 'start' }],
'no-warning-comments': [0, { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
// disallow use of the with statement
'no-with': 2,
// require use of the second argument for parseInt()
'radix': 2,
radix: 2,
// requires to declare all vars on top of their containing scope
'vars-on-top': 2,
// require immediate function invocation to be wrapped in parentheses
'wrap-iife': [2, 'any'],
// http://eslint.org/docs/rules/wrap-iife.html
'wrap-iife': [2, 'outside'],
// require or disallow Yoda conditions
'yoda': 2
yoda: 2
}
};

View File

@@ -1,60 +1,103 @@
module.exports = {
'rules': {
// disallow trailing commas in object literals
rules: {
// require trailing commas in multiline object literals
'comma-dangle': [2, 'always-multiline'],
// disallow assignment in conditional expressions
'no-cond-assign': [2, 'always'],
// disallow use of console
'no-console': 1,
// disallow use of constant expressions in conditions
'no-constant-condition': 1,
// disallow control characters in regular expressions
'no-control-regex': 2,
// disallow use of debugger
'no-debugger': 1,
'no-debugger': 2,
// disallow duplicate arguments in functions
'no-dupe-args': 2,
// disallow duplicate keys when creating object literals
'no-dupe-keys': 2,
// disallow a duplicate case label.
'no-duplicate-case': 2,
// disallow the use of empty character classes in regular expressions
'no-empty-character-class': 2,
// disallow empty statements
'no-empty': 2,
// disallow the use of empty character classes in regular expressions
'no-empty-character-class': 2,
// disallow assigning to the exception in a catch block
'no-ex-assign': 2,
// disallow double-negation boolean casts in a boolean context
'no-extra-boolean-cast': 0,
// http://eslint.org/docs/rules/no-extra-boolean-cast
'no-extra-boolean-cast': 2,
// disallow unnecessary parentheses
'no-extra-parens': [2, 'functions'],
// http://eslint.org/docs/rules/no-extra-parens
'no-extra-parens': [0, 'all', {
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: false,
}],
// disallow unnecessary semicolons
'no-extra-semi': 2,
// disallow overwriting functions written as function declarations
'no-func-assign': 2,
// disallow function or variable declarations in nested blocks
'no-inner-declarations': 2,
// disallow invalid regular expression strings in the RegExp constructor
'no-invalid-regexp': 2,
// disallow irregular whitespace outside of strings and comments
'no-irregular-whitespace': 2,
// disallow negation of the left operand of an in expression
'no-negated-in-lhs': 2,
// disallow the use of object properties of the global object (Math and JSON) as functions
'no-obj-calls': 2,
// disallow use of Object.prototypes builtins directly
// http://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 2,
// disallow multiple spaces in a regular expression literal
'no-regex-spaces': 2,
// disallow sparse arrays
'no-sparse-arrays': 2,
// Avoid code that looks like two expressions but is actually one
// http://eslint.org/docs/rules/no-unexpected-multiline
'no-unexpected-multiline': 2,
// disallow unreachable statements after a return, throw, continue, or break statement
'no-unreachable': 2,
// disallow return/throw/break/continue inside finally blocks
// http://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 2,
// disallow comparisons with the value NaN
'use-isnan': 2,
// ensure JSDoc comments are valid
// http://eslint.org/docs/rules/valid-jsdoc
'valid-jsdoc': 0,
// ensure that the results of typeof are compared against a valid string
'valid-typeof': 2,
// Avoid code that looks like two expressions but is actually one
'no-unexpected-multiline': 0
'valid-typeof': 2
}
};

View File

@@ -0,0 +1,145 @@
module.exports = {
env: {
es6: true
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
generators: false,
objectLiteralDuplicateProperties: false
}
},
rules: {
// enforces no braces where they can be omitted
// http://eslint.org/docs/rules/arrow-body-style
'arrow-body-style': [2, 'as-needed'],
// require parens in arrow function arguments
'arrow-parens': 0,
// require space before/after arrow function's arrow
// http://eslint.org/docs/rules/arrow-spacing
'arrow-spacing': [2, { before: true, after: true }],
// verify super() callings in constructors
'constructor-super': 2,
// enforce the spacing around the * in generator functions
// http://eslint.org/docs/rules/generator-star-spacing
'generator-star-spacing': [2, { before: false, after: true }],
// disallow modifying variables of class declarations
// http://eslint.org/docs/rules/no-class-assign
'no-class-assign': 2,
// disallow arrow functions where they could be confused with comparisons
// http://eslint.org/docs/rules/no-confusing-arrow
'no-confusing-arrow': [2, {
allowParens: true,
}],
// disallow modifying variables that are declared using const
'no-const-assign': 2,
// disallow duplicate class members
// http://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 2,
// disallow importing from the same path more than once
// http://eslint.org/docs/rules/no-duplicate-imports
'no-duplicate-imports': 2,
// disallow symbol constructor
// http://eslint.org/docs/rules/no-new-symbol
'no-new-symbol': 2,
// disallow specific imports
// http://eslint.org/docs/rules/no-restricted-imports
'no-restricted-imports': 0,
// disallow to use this/super before super() calling in constructors.
// http://eslint.org/docs/rules/no-this-before-super
'no-this-before-super': 2,
// disallow useless computed property keys
// http://eslint.org/docs/rules/no-useless-computed-key
'no-useless-computed-key': 2,
// disallow unnecessary constructor
// http://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 2,
// disallow renaming import, export, and destructured assignments to the same name
// http://eslint.org/docs/rules/no-useless-rename
'no-useless-rename': [2, {
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
}],
// require let or const instead of var
'no-var': 2,
// require method and property shorthand syntax for object literals
// http://eslint.org/docs/rules/object-shorthand
'object-shorthand': [2, 'always', {
ignoreConstructors: false,
avoidQuotes: true,
}],
// suggest using arrow functions as callbacks
'prefer-arrow-callback': [2, {
allowNamedFunctions: false,
allowUnboundThis: true,
}],
// suggest using of const declaration for variables that are never modified after declared
'prefer-const': [2, {
destructuring: 'any',
ignoreReadBeforeAssign: true,
}],
// suggest using Reflect methods where applicable
// http://eslint.org/docs/rules/prefer-reflect
// TODO: enable
'prefer-reflect': 0,
// use rest parameters instead of arguments
// http://eslint.org/docs/rules/prefer-rest-params
'prefer-rest-params': 2,
// suggest using the spread operator instead of .apply()
// http://eslint.org/docs/rules/prefer-spread
'prefer-spread': 2,
// suggest using template literals instead of string concatenation
// http://eslint.org/docs/rules/prefer-template
'prefer-template': 2,
// disallow generator functions that do not have yield
// http://eslint.org/docs/rules/require-yield
'require-yield': 2,
// enforce spacing between object rest-spread
// http://eslint.org/docs/rules/rest-spread-spacing
'rest-spread-spacing': [2, 'never'],
// import sorting
// http://eslint.org/docs/rules/sort-imports
'sort-imports': [0, {
ignoreCase: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
}],
// enforce usage of spacing in template strings
// http://eslint.org/docs/rules/template-curly-spacing
'template-curly-spacing': 2,
// enforce spacing around the * in yield* expressions
// http://eslint.org/docs/rules/yield-star-spacing
'yield-star-spacing': [2, 'after']
}
};

View File

@@ -0,0 +1,132 @@
module.exports = {
env: {
es6: true
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module'
},
plugins: [
'import'
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.json']
}
},
'import/extensions': [
'node_modules',
],
'import/core-modules': [
],
'import/ignore': [
'node_modules',
'\\.(coffee|scss|css|less|hbs|svg|json)$',
],
},
rules: {
// Static analysis:
// ensure imports point to files/modules that can be resolved
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
'import/no-unresolved': [2, { commonjs: true }],
// ensure named imports coupled with named exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
'import/named': 0,
// ensure default import coupled with default export
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
'import/default': 0,
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
'import/namespace': 0,
// Helpful warnings:
// disallow invalid exports, e.g. multiple defaults
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
'import/export': 2,
// do not allow a default import name to match a named export
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
'import/no-named-as-default': 2,
// warn on accessing default export property names that are also named exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
'import/no-named-as-default-member': 2,
// disallow use of jsdoc-marked-deprecated imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
'import/no-deprecated': 0,
// Forbid the use of extraneous packages
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
'import/no-extraneous-dependencies': [2, {
devDependencies: false,
optionalDependencies: false,
}],
// Forbid mutable exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
'import/no-mutable-exports': 2,
// Module systems:
// disallow require()
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
'import/no-commonjs': 0,
// disallow AMD require/define
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
'import/no-amd': 2,
// No Node.js builtin modules
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
// TODO: enable?
'import/no-nodejs-modules': 0,
// Style guide:
// disallow non-import statements appearing before import statements
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
'import/imports-first': [2, 'absolute-first'],
// disallow duplicate imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'import/no-duplicates': 2,
// disallow namespace imports
// TODO: enable?
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
'import/no-namespace': 0,
// Ensure consistent use of file extension within the import path
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
// TODO: enable when https://github.com/benmosher/eslint-plugin-import/issues/390 is resolved
'import/extensions': [0, 'never'],
// Enforce a convention in module import order
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
// TODO: enable?
'import/order': [0, {
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'never',
}],
// Require a newline after the last import/require in a group
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
'import/newline-after-import': 2,
// Require modules with a single export to use a default export
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
'import/prefer-default-export': 2,
// Restrict which files can be imported in a given folder
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
'import/no-restricted-paths': 0,
},
};

View File

@@ -1,23 +1,39 @@
module.exports = {
'env': {
'node': true
env: {
node: true
},
'rules': {
rules: {
// enforce return after a callback
'callback-return': 0,
// require all requires be top-level
// http://eslint.org/docs/rules/global-require
'global-require': 2,
// enforces error handling in callbacks (node environment)
'handle-callback-err': 0,
// disallow mixing regular variable and require declarations
'no-mixed-requires': [0, false],
// disallow use of new operator with the require function
'no-new-require': 0,
'no-new-require': 2,
// disallow string concatenation with __dirname and __filename
'no-path-concat': 0,
// http://eslint.org/docs/rules/no-path-concat
'no-path-concat': 2,
// disallow use of process.env
'no-process-env': 0,
// disallow process.exit()
'no-process-exit': 0,
// restrict usage of specified node modules
'no-restricted-modules': 0,
// disallow use of synchronous methods (off by default)
'no-sync': 0
'no-sync': 0,
}
};

View File

@@ -0,0 +1,6 @@
module.exports = {
rules: {
// babel inserts `'use strict';` for us
strict: [2, 'never']
}
};

View File

@@ -0,0 +1,305 @@
module.exports = {
rules: {
// enforce spacing inside array brackets
'array-bracket-spacing': [2, 'never'],
// enforce spacing inside single-line blocks
// http://eslint.org/docs/rules/block-spacing
'block-spacing': [2, 'always'],
// enforce one true brace style
'brace-style': [2, '1tbs', { allowSingleLine: true }],
// require camel case names
camelcase: [2, { properties: 'never' }],
// enforce spacing before and after comma
'comma-spacing': [2, { before: false, after: true }],
// enforce one true comma style
'comma-style': [2, 'last'],
// disallow padding inside computed properties
'computed-property-spacing': [2, 'never'],
// enforces consistent naming when capturing the current execution context
'consistent-this': 0,
// enforce newline at the end of file, with no multiple empty lines
'eol-last': 2,
// require function expressions to have a name
'func-names': 1,
// enforces use of function declarations or expressions
'func-style': 0,
// Blacklist certain identifiers to prevent them being used
// http://eslint.org/docs/rules/id-blacklist
'id-blacklist': 0,
// this option enforces minimum and maximum identifier lengths
// (variable names, property names etc.)
'id-length': 0,
// require identifiers to match the provided regular expression
'id-match': 0,
// this option sets a specific tab width for your code
// http://eslint.org/docs/rules/indent
indent: [2, 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1 }],
// specify whether double or single quotes should be used in JSX attributes
// http://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': [0, 'prefer-double'],
// enforces spacing between keys and values in object literal properties
'key-spacing': [2, { beforeColon: false, afterColon: true }],
// require a space before & after certain keywords
'keyword-spacing': [2, {
before: true,
after: true,
overrides: {
return: { after: true },
throw: { after: true },
case: { after: true }
}
}],
// disallow mixed 'LF' and 'CRLF' as linebreaks
// http://eslint.org/docs/rules/linebreak-style
'linebreak-style': [2, 'unix'],
// enforces empty lines around comments
'lines-around-comment': 0,
// specify the maximum depth that blocks can be nested
'max-depth': [0, 4],
// specify the maximum length of a line in your program
// http://eslint.org/docs/rules/max-len
'max-len': [2, 100, 2, {
ignoreUrls: true,
ignoreComments: false
}],
// specify the max number of lines in a file
// http://eslint.org/docs/rules/max-lines
'max-lines': [0, {
max: 300,
skipBlankLines: true,
skipComments: true
}],
// specify the maximum depth callbacks can be nested
'max-nested-callbacks': 0,
// limits the number of parameters that can be used in the function declaration.
'max-params': [0, 3],
// specify the maximum number of statement allowed in a function
'max-statements': [0, 10],
// restrict the number of statements per line
// http://eslint.org/docs/rules/max-statements-per-line
'max-statements-per-line': [0, { max: 1 }],
// require multiline ternary
// http://eslint.org/docs/rules/multiline-ternary
'multiline-ternary': 0,
// require a capital letter for constructors
'new-cap': [2, { newIsCap: true }],
// disallow the omission of parentheses when invoking a constructor with no arguments
// http://eslint.org/docs/rules/new-parens
'new-parens': 2,
// allow/disallow an empty newline after var statement
'newline-after-var': 0,
// http://eslint.org/docs/rules/newline-before-return
'newline-before-return': 0,
// enforces new line after each method call in the chain to make it
// more readable and easy to maintain
// http://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': [2, { ignoreChainWithDepth: 4 }],
// disallow use of the Array constructor
'no-array-constructor': 2,
// disallow use of bitwise operators
// http://eslint.org/docs/rules/no-bitwise
// TODO: enable
'no-bitwise': 0,
// disallow use of the continue statement
// http://eslint.org/docs/rules/no-continue
'no-continue': 2,
// disallow comments inline after code
'no-inline-comments': 0,
// disallow if as the only statement in an else block
// http://eslint.org/docs/rules/no-lonely-if
'no-lonely-if': 2,
// disallow un-paren'd mixes of different operators
// http://eslint.org/docs/rules/no-mixed-operators
'no-mixed-operators': [2, {
groups: [
['+', '-', '*', '/', '%', '**'],
['&', '|', '^', '~', '<<', '>>', '>>>'],
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
['&&', '||'],
['in', 'instanceof']
],
allowSamePrecedence: false
}],
// disallow mixed spaces and tabs for indentation
'no-mixed-spaces-and-tabs': 2,
// disallow multiple empty lines and only one newline at the end
'no-multiple-empty-lines': [2, { max: 2, maxEOF: 1 }],
// disallow negated conditions
// http://eslint.org/docs/rules/no-negated-condition
'no-negated-condition': 0,
// disallow nested ternary expressions
'no-nested-ternary': 2,
// disallow use of the Object constructor
'no-new-object': 2,
// disallow use of unary operators, ++ and --
'no-plusplus': 0,
// disallow certain syntax forms
// http://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': [
2,
'DebuggerStatement',
'ForInStatement',
'LabeledStatement',
'WithStatement',
],
// disallow space between function identifier and application
'no-spaced-func': 2,
// disallow tab characters entirely
// TODO: enable
'no-tabs': 0,
// disallow the use of ternary operators
'no-ternary': 0,
// disallow trailing whitespace at the end of lines
'no-trailing-spaces': 2,
// disallow dangling underscores in identifiers
'no-underscore-dangle': [2, { allowAfterThis: false }],
// disallow the use of Boolean literals in conditional expressions
// also, prefer `a || b` over `a ? a : b`
// http://eslint.org/docs/rules/no-unneeded-ternary
'no-unneeded-ternary': [2, { defaultAssignment: false }],
// disallow whitespace before properties
// http://eslint.org/docs/rules/no-whitespace-before-property
'no-whitespace-before-property': 2,
// require padding inside curly braces
'object-curly-spacing': [2, 'always'],
// enforce line breaks between braces
// http://eslint.org/docs/rules/object-curly-newline
// TODO: enable once https://github.com/eslint/eslint/issues/6488 is resolved
'object-curly-newline': [0, {
ObjectExpression: { minProperties: 0, multiline: true },
ObjectPattern: { minProperties: 0, multiline: true }
}],
// enforce "same line" or "multiple line" on object properties.
// http://eslint.org/docs/rules/object-property-newline
'object-property-newline': [2, {
allowMultiplePropertiesPerLine: true,
}],
// allow just one var statement per function
'one-var': [2, 'never'],
// require a newline around variable declaration
// http://eslint.org/docs/rules/one-var-declaration-per-line
'one-var-declaration-per-line': [2, 'always'],
// require assignment operator shorthand where possible or prohibit it entirely
// http://eslint.org/docs/rules/operator-assignment
'operator-assignment': [2, 'always'],
// enforce operators to be placed before or after line breaks
'operator-linebreak': 0,
// enforce padding within blocks
'padded-blocks': [2, 'never'],
// require quotes around object literal property names
// http://eslint.org/docs/rules/quote-props.html
'quote-props': [2, 'as-needed', { keywords: false, unnecessary: true, numbers: false }],
// specify whether double or single quotes should be used
quotes: [2, 'single', { avoidEscape: true }],
// do not require jsdoc
// http://eslint.org/docs/rules/require-jsdoc
'require-jsdoc': 0,
// require or disallow use of semicolons instead of ASI
semi: [2, 'always'],
// enforce spacing before and after semicolons
'semi-spacing': [2, { before: false, after: true }],
// sort variables within the same declaration block
'sort-vars': 0,
// require or disallow space before blocks
'space-before-blocks': 2,
// require or disallow space before function opening parenthesis
// http://eslint.org/docs/rules/space-before-function-paren
'space-before-function-paren': [2, { anonymous: 'always', named: 'never' }],
// require or disallow spaces inside parentheses
'space-in-parens': [2, 'never'],
// require spaces around operators
'space-infix-ops': 2,
// Require or disallow spaces before/after unary operators
// http://eslint.org/docs/rules/space-unary-ops
'space-unary-ops': [2, {
words: true,
nonwords: false,
overrides: {
},
}],
// require or disallow a space immediately following the // or /* in a comment
'spaced-comment': [2, 'always', {
exceptions: ['-', '+'],
markers: ['=', '!'] // space here to support sprockets directives
}],
// require or disallow the Unicode Byte Order Mark
// http://eslint.org/docs/rules/unicode-bom
'unicode-bom': [2, 'never'],
// require regex literals to be wrapped in parentheses
'wrap-regex': 0
}
};

View File

@@ -1,25 +1,40 @@
module.exports = {
'rules': {
rules: {
// enforce or disallow variable initializations at definition
'init-declarations': 0,
// disallow the catch clause parameter name being the same as a variable in the outer scope
'no-catch-shadow': 0,
// disallow deletion of variables
'no-delete-var': 2,
// disallow labels that share a name with a variable
'no-label-var': 0,
// disallow shadowing of names such as arguments
'no-shadow-restricted-names': 2,
// http://eslint.org/docs/rules/no-label-var
'no-label-var': 2,
// disallow specific globals
'no-restricted-globals': 0,
// disallow declaration of variables already declared in the outer scope
'no-shadow': 2,
// disallow use of undefined when initializing variables
'no-undef-init': 0,
// disallow shadowing of names such as arguments
'no-shadow-restricted-names': 2,
// disallow use of undeclared variables unless mentioned in a /*global */ block
'no-undef': 2,
// disallow use of undefined when initializing variables
'no-undef-init': 2,
// disallow use of undefined variable
// TODO: enable?
'no-undefined': 0,
// disallow declaration of variables that are not used in the code
'no-unused-vars': [2, {'vars': 'local', 'args': 'after-used'}],
'no-unused-vars': [2, { vars: 'local', args: 'after-used' }],
// disallow use of variables before they are defined
'no-use-before-define': 2
}

View File

@@ -0,0 +1,12 @@
{
"rules": {
// disabled because I find it tedious to write tests while following this
// rule
"no-shadow": 0,
// tests uses `t` for tape
"id-length": [2, {"min": 2, "properties": "never", "exceptions": ["t"]}],
"import/no-extraneous-dependencies": [2, {
"devDependencies": true
}],
}
}

View File

@@ -0,0 +1,29 @@
import fs from 'fs';
import path from 'path';
import test from 'tape';
import index from '../';
const files = { index };
fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => {
files[name] = require(`../rules/${name}`); // eslint-disable-line global-require
});
Object.keys(files).forEach(name => {
const config = files[name];
test(`${name}: does not reference react`, t => {
t.plan(2);
// scan plugins for react and fail if it is found
const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins') &&
config.plugins.indexOf('react') !== -1;
t.notOk(hasReactPlugin, 'there is no react plugin');
// scan rules for react/ and fail if any exist
const reactRuleIds = Object.keys(config.rules)
.filter(ruleId => ruleId.indexOf('react/') === 0);
t.deepEquals(reactRuleIds, [], 'there are no react/ rules');
});
});

View File

@@ -0,0 +1,3 @@
{
"presets": ["airbnb"]
}

View File

@@ -1,5 +1,5 @@
{
"extends": "airbnb",
"extends": "./index.js",
"rules": {
// disable requiring trailing commas because it might be nice to revert to
// being JSON at some point, and I don't want to make big changes now.

View File

@@ -0,0 +1,228 @@
9.0.1 / 2016-05-08
==================
- [patch] update `eslint-config-airbnb-base` to v3.0.1
9.0.0 / 2016-05-07
==================
- [breaking] update `eslint-config-airbnb-base` to v3
- [deps] update `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`
8.0.0 / 2016-04-21
==================
- [breaking] Migrate non-React rules to a separate linter config (`eslint-config-airbnb-base`)
- [breaking] disallow empty methods
- [breaking] disallow empty restructuring patterns
- [breaking] enable `no-restricted-syntax` rule
- [breaking] enable `global-require` rule
- [breaking] [react] enable `react/jsx-curly-spacing` rule ([#693](https://github.com/airbnb/javascript/issues/693))
- [semver-minor] [react] Add `react/jsx-first-prop-new-line` rule
- [semver-minor] [react] enable `jsx-equals-spacing` rule
- [semver-minor] [react] enable `jsx-indent` rule
- [semver-minor] enforce spacing inside single-line blocks
- [semver-minor] enforce `no-underscore-dangle`
- [semver-minor] Enable import/no-unresolved and import/export rules ([#825](https://github.com/airbnb/javascript/issues/825))
- [semver-patch] Enable `no-useless-concat` rule which `prefer-template` already covers
- [semver-patch] Allow `== null` ([#542](https://github.com/airbnb/javascript/issues/542))
- [dev deps / peer deps] update `eslint`, `eslint-plugin-react`, `eslint-plugin-import`
- [dev deps / peer deps] update `eslint-plugin-jsx-a11y` and rename rules ([#838](https://github.com/airbnb/javascript/issues/838))
- [refactor] [react] separate a11y rules to their own file
- [refactor] Add missing disabled rules.
- [tests] Add `eslint-find-rules` to prevent missing rules
7.0.0 / 2016-04-11
==================
- [react] [breaking] Add accessibility rules to the React style guide + `eslint-plugin-a11y`
- [breaking] enable `react/require-render-return`
- [breaking] Add `no-dupe-class-members` rule + section ([#785](https://github.com/airbnb/javascript/issues/785))
- [breaking] error on debugger statements
- [breaking] add `no-useless-escape` rule
- [breaking] add `no-duplicate-imports` rule
- [semver-minor] enable `jsx-pascal-case` rule
- [deps] update `eslint`, `react`
- [dev deps] update `eslint`, `eslint-plugin-react`
6.2.0 / 2016-03-22
==================
- [new] Allow arrow functions in JSX props
- [fix] re-enable `no-confusing-arrow` rule, with `allowParens` option enabled ([#752](https://github.com/airbnb/javascript/issues/752), [#791](https://github.com/airbnb/javascript/issues/791))
- [dev deps] update `tape`, `eslint`, `eslint-plugin-react`
- [peer deps] update `eslint`, `eslint-plugin-react`
6.1.0 / 2016-02-22
==================
- [new] enable [`react/prefer-stateless-function`][react/prefer-stateless-function]
- [dev deps] update `react-plugin-eslint`, `eslint`, `tape`
6.0.2 / 2016-02-22
==================
- [fix] disable [`no-confusing-arrow`][no-confusing-arrow] due to an `eslint` bug ([#752](https://github.com/airbnb/javascript/issues/752))
6.0.1 / 2016-02-21
==================
- [fix] disable [`newline-per-chained-call`][newline-per-chained-call] due to an `eslint` bug ([#748](https://github.com/airbnb/javascript/issues/748))
6.0.0 / 2016-02-21
==================
- [breaking] enable [`array-callback-return`][array-callback-return]
- [breaking] enable [`no-confusing-arrow`][no-confusing-arrow]
- [breaking] enable [`no-new-symbol`][no-new-symbol]
- [breaking] enable [`no-restricted-imports`][no-restricted-imports]
- [breaking] enable [`no-useless-constructor`][no-useless-constructor]
- [breaking] enable [`prefer-rest-params`][prefer-rest-params]
- [breaking] enable [`template-curly-spacing`][template-curly-spacing]
- [breaking] enable [`newline-per-chained-call`][newline-per-chained-call]
- [breaking] enable [`one-var-declaration-per-line`][one-var-declaration-per-line]
- [breaking] enable [`no-self-assign`][no-self-assign]
- [breaking] enable [`no-whitespace-before-property`][no-whitespace-before-property]
- [breaking] [react] enable [`react/jsx-space-before-closing`][react/jsx-space-before-closing]
- [breaking] [react] enable `static-methods` at top of [`react/sort-comp`][react/sort-comp]
- [breaking] [react] don't `ignoreTranspilerName` for [`react/display-name`][react/display-name]
- [peer+dev deps] update `eslint`, `eslint-plugin-react` ([#730](https://github.com/airbnb/javascript/issues/730))
5.0.1 / 2016-02-13
==================
- [fix] `eslint` peerDep should not include breaking changes
5.0.0 / 2016-02-03
==================
- [breaking] disallow unneeded ternary expressions
- [breaking] Avoid lexical declarations in case/default clauses
- [dev deps] update `babel-tape-runner`, `eslint-plugin-react`, `react`, `tape`
4.0.0 / 2016-01-22
==================
- [breaking] require outer IIFE wrapping; flesh out guide section
- [minor] Add missing [`arrow-body-style`][arrow-body-style], [`prefer-template`][prefer-template] rules ([#678](https://github.com/airbnb/javascript/issues/678))
- [minor] Add [`prefer-arrow-callback`][prefer-arrow-callback] to ES6 rules (to match the guide) ([#677](https://github.com/airbnb/javascript/issues/677))
- [Tests] run `npm run lint` as part of tests; fix errors
- [Tests] use `parallelshell` to parallelize npm run-scripts
3.1.0 / 2016-01-07
==================
- [minor] Allow multiple stateless components in a single file
3.0.2 / 2016-01-06
==================
- [fix] Ignore URLs in [`max-len`][max-len] ([#664](https://github.com/airbnb/javascript/issues/664))
3.0.1 / 2016-01-06
==================
- [fix] because we use babel, keywords should not be quoted
3.0.0 / 2016-01-04
==================
- [breaking] enable [`quote-props`][quote-props] rule ([#632](https://github.com/airbnb/javascript/issues/632))
- [breaking] Define a max line length of 100 characters ([#639](https://github.com/airbnb/javascript/issues/639))
- [breaking] [react] Minor cleanup for the React styleguide, add [`react/jsx-no-bind`][react/jsx-no-bind] ([#619](https://github.com/airbnb/javascript/issues/619))
- [breaking] update best-practices config to prevent parameter object manipulation ([#627](https://github.com/airbnb/javascript/issues/627))
- [minor] Enable [`react/no-is-mounted`][react/no-is-mounted] rule (#635, #633)
- [minor] Sort [`react/prefer-es6-class`][react/prefer-es6-class] alphabetically ([#634](https://github.com/airbnb/javascript/issues/634))
- [minor] enable [`react/prefer-es6-class`][react/prefer-es6-class] rule
- Permit strict mode in "legacy" config
- [react] add missing rules from `eslint-plugin-react` (enforcing where necessary) ([#581](https://github.com/airbnb/javascript/issues/581))
- [dev deps] update `eslint-plugin-react`
2.1.1 / 2015-12-15
==================
- [fix] Remove deprecated [`react/jsx-quotes`][react/jsx-quotes] ([#622](https://github.com/airbnb/javascript/issues/622))
2.1.0 / 2015-12-15
==================
- [fix] use `require.resolve` to allow nested `extend`s ([#582](https://github.com/airbnb/javascript/issues/582))
- [new] enable [`object-shorthand`][object-shorthand] rule ([#621](https://github.com/airbnb/javascript/issues/621))
- [new] enable [`arrow-spacing`][arrow-spacing] rule ([#517](https://github.com/airbnb/javascript/issues/517))
- [docs] flesh out react rule defaults ([#618](https://github.com/airbnb/javascript/issues/618))
2.0.0 / 2015-12-03
==================
- [breaking] [`space-before-function-paren`][space-before-function-paren]: require function spacing: `function <optional name>(` ([#605](https://github.com/airbnb/javascript/issues/605))
- [breaking] [`indent`][indent]: Fix switch statement indentation rule ([#606](https://github.com/airbnb/javascript/issues/606))
- [breaking] [`array-bracket-spacing`][array-bracket-spacing], [`computed-property-spacing`][computed-property-spacing]: disallow spacing inside brackets ([#594](https://github.com/airbnb/javascript/issues/594))
- [breaking] [`object-curly-spacing`][object-curly-spacing]: require padding inside curly braces ([#594](https://github.com/airbnb/javascript/issues/594))
- [breaking] [`space-in-parens`][space-in-parens]: disallow spaces in parens ([#594](https://github.com/airbnb/javascript/issues/594))
1.0.2 / 2015-11-25
==================
- [breaking] [`no-multiple-empty-lines`][no-multiple-empty-lines]: only allow 1 blank line at EOF ([#578](https://github.com/airbnb/javascript/issues/578))
- [new] `restParams`: enable rest params ([#592](https://github.com/airbnb/javascript/issues/592))
1.0.1 / 2015-11-25
==================
- *erroneous publish*
1.0.0 / 2015-11-08
==================
- require `eslint` `v1.0.0` or higher
- remove `babel-eslint` dependency
0.1.1 / 2015-11-05
==================
- remove [`id-length`][id-length] rule ([#569](https://github.com/airbnb/javascript/issues/569))
- enable [`no-mixed-spaces-and-tabs`][no-mixed-spaces-and-tabs] ([#539](https://github.com/airbnb/javascript/issues/539))
- enable [`no-const-assign`][no-const-assign] ([#560](https://github.com/airbnb/javascript/issues/560))
- enable [`space-before-keywords`][space-before-keywords] ([#554](https://github.com/airbnb/javascript/issues/554))
0.1.0 / 2015-11-05
==================
- switch to modular rules files courtesy the [eslint-config-default][ecd] project and [@taion][taion]. [PR][pr-modular]
- export `eslint-config-airbnb/legacy` for ES5-only users. `eslint-config-airbnb/legacy` does not require the `babel-eslint` parser. [PR][pr-legacy]
0.0.9 / 2015-09-24
==================
- add rule [`no-undef`][no-undef]
- add rule [`id-length`][id-length]
0.0.8 / 2015-08-21
==================
- now has a changelog
- now is modular (see instructions above for with react and without react versions)
0.0.7 / 2015-07-30
==================
- TODO: fill in
[ecd]: https://github.com/walmartlabs/eslint-config-defaults
[taion]: https://github.com/taion
[pr-modular]: https://github.com/airbnb/javascript/pull/526
[pr-legacy]: https://github.com/airbnb/javascript/pull/527
[array-bracket-spacing]: http://eslint.org/docs/rules/array-bracket-spacing
[array-callback-return]: http://eslint.org/docs/rules/array-callback-return
[arrow-body-style]: http://eslint.org/docs/rules/arrow-body-style
[arrow-spacing]: http://eslint.org/docs/rules/arrow-spacing
[computed-property-spacing]: http://eslint.org/docs/rules/computed-property-spacing
[id-length]: http://eslint.org/docs/rules/id-length
[indent]: http://eslint.org/docs/rules/indent
[max-len]: http://eslint.org/docs/rules/max-len
[newline-per-chained-call]: http://eslint.org/docs/rules/newline-per-chained-call
[no-confusing-arrow]: http://eslint.org/docs/rules/no-confusing-arrow
[no-const-assign]: http://eslint.org/docs/rules/no-const-assign
[no-mixed-spaces-and-tabs]: http://eslint.org/docs/rules/no-mixed-spaces-and-tabs
[no-multiple-empty-lines]: http://eslint.org/docs/rules/no-multiple-empty-lines
[no-new-symbol]: http://eslint.org/docs/rules/no-new-symbol
[no-restricted-imports]: http://eslint.org/docs/rules/no-restricted-imports
[no-self-assign]: http://eslint.org/docs/rules/no-self-assign
[no-undef]: http://eslint.org/docs/rules/no-undef
[no-useless-constructor]: http://eslint.org/docs/rules/no-useless-constructor
[no-whitespace-before-property]: http://eslint.org/docs/rules/no-whitespace-before-property
[object-curly-spacing]: http://eslint.org/docs/rules/object-curly-spacing
[object-shorthand]: http://eslint.org/docs/rules/object-shorthand
[one-var-declaration-per-line]: http://eslint.org/docs/rules/one-var-declaration-per-line
[prefer-arrow-callback]: http://eslint.org/docs/rules/prefer-arrow-callback
[prefer-rest-params]: http://eslint.org/docs/rules/prefer-rest-params
[prefer-template]: http://eslint.org/docs/rules/prefer-template
[quote-props]: http://eslint.org/docs/rules/quote-props
[space-before-function-paren]: http://eslint.org/docs/rules/space-before-function-paren
[space-before-keywords]: http://eslint.org/docs/rules/space-before-keywords
[space-in-parens]: http://eslint.org/docs/rules/space-in-parens
[template-curly-spacing]: http://eslint.org/docs/rules/template-curly-spacing
[react/jsx-space-before-closing]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
[react/sort-comp]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
[react/display-name]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
[react/jsx-no-bind]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
[react/no-is-mounted]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
[react/prefer-es6-class]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
[react/jsx-quotes]: https://github.com/yannickcr/eslint-plugin-react/blob/f817e37beddddc84b4788969f07c524fa7f0823b/docs/rules/jsx-quotes.md
[react/prefer-stateless-function]: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md

View File

@@ -1,5 +1,7 @@
# eslint-config-airbnb
[![npm version](https://badge.fury.io/js/eslint-config-airbnb.svg)](http://badge.fury.io/js/eslint-config-airbnb)
This package provides Airbnb's .eslintrc as an extensible shared config.
## Usage
@@ -8,25 +10,30 @@ We export three ESLint configurations for your usage.
### eslint-config-airbnb
Our default export contains all of our ESLint rules, including EcmaScript 6+
and React. It requires `eslint`, `babel-eslint`, and `eslint-plugin-react`.
Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`.
1. `npm install --save-dev eslint-config-airbnb babel-eslint eslint-plugin-react eslint`
2. add `"extends": "airbnb"` to your .eslintrc
1. Ensure packages are installed with correct version numbers by running:
```sh
(
export PKG=eslint-config-airbnb;
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
)
```
Which produces and runs a command like:
```sh
npm install --save-dev eslint-config-airbnb eslint@^2.9.0 eslint-plugin-jsx-a11y@^1.2.0 eslint-plugin-import@^1.7.0 eslint-plugin-react@^5.0.1
```
2. Add `"extends": "airbnb"` to your .eslintrc
### eslint-config-airbnb/base
Lints ES6+ but does not lint React. Requires `eslint` and `babel-eslint`.
1. `npm install --save-dev eslint-config-airbnb babel-eslint eslint`
2. add `"extends": "airbnb/base"` to your .eslintrc
This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base).
### eslint-config-airbnb/legacy
Lints ES5 and below. Only requires `eslint`.
1. `npm install --save-dev eslint-config-airbnb eslint`
2. add `"extends": "airbnb/legacy"` to your .eslintrc
This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base).
See [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript) and
the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files)
@@ -34,34 +41,8 @@ for more information.
## Improving this config
Consider adding test cases if you're making complicated rules changes, like
anything involving regexes. Perhaps in a distant future, we could use literate
programming to structure our README as test cases for our .eslintrc?
Consider adding test cases if you're making complicated rules changes, like anything involving regexes. Perhaps in a distant future, we could use literate programming to structure our README as test cases for our .eslintrc?
You can run tests with `npm test`.
You can make sure this module lints with itself using `npm run lint`.
## Changelog
### 0.1.0
- switch to modular rules files courtesy the [eslint-config-default][ecd]
project and [@taion][taion]. [PR][pr-modular]
- export `eslint-config-airbnb/legacy` for ES5-only users.
`eslint-config-airbnb/legacy` does not require the `babel-eslint` parser.
[PR][pr-legacy]
[ecd]: https://github.com/walmartlabs/eslint-config-defaults
[taion]: https://github.com/taion
[pr-modular]: https://github.com/airbnb/javascript/pull/526
[pr-legacy]: https://github.com/airbnb/javascript/pull/527
### 0.0.9
- add rule no-undef
- add rule id-length
### 0.0.8
- now has a changelog
- now is modular (see instructions above for with react and without react versions)

View File

@@ -1,8 +1,4 @@
module.exports = {
'extends': [
'eslint-config-airbnb/legacy',
'eslint-config-airbnb/rules/es6',
],
'parser': 'babel-eslint',
'rules': {}
extends: ['eslint-config-airbnb-base'].map(require.resolve),
rules: {},
};

View File

@@ -1,7 +1,9 @@
module.exports = {
'extends': [
'eslint-config-airbnb/base',
'eslint-config-airbnb/rules/react',
],
extends: [
'eslint-config-airbnb-base',
'eslint-config-airbnb-base/rules/strict',
'./rules/react',
'./rules/react-a11y',
].map(require.resolve),
rules: {}
};

View File

@@ -1,21 +1,4 @@
module.exports = {
'extends': [
'eslint-config-airbnb/rules/best-practices',
'eslint-config-airbnb/rules/errors',
'eslint-config-airbnb/rules/legacy',
'eslint-config-airbnb/rules/node',
'eslint-config-airbnb/rules/strict',
'eslint-config-airbnb/rules/style',
'eslint-config-airbnb/rules/variables'
],
'env': {
'browser': true,
'node': true,
'amd': false,
'mocha': false,
'jasmine': false
},
'ecmaFeatures': {},
'globals': {},
'rules': {}
extends: ['eslint-config-airbnb-base/legacy'].map(require.resolve),
rules: {},
};

View File

@@ -1 +0,0 @@
..

View File

@@ -1,11 +1,15 @@
{
"name": "eslint-config-airbnb",
"version": "0.1.0",
"version": "9.0.1",
"description": "Airbnb's ESLint config, following our styleguide",
"main": "index.js",
"scripts": {
"lint": "eslint .",
"test": "babel-tape-runner ./test/test-*.js"
"tests-only": "babel-tape-runner ./test/test-*.js",
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test)",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"travis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link eslint-config-airbnb-base && npm run --silent test ; npm unlink eslint-config-airbnb-base >/dev/null &"
},
"repository": {
"type": "git",
@@ -20,17 +24,48 @@
"styleguide"
],
"author": "Jake Teton-Landis (https://twitter.com/@jitl)",
"contributors": [
{
"name": "Jake Teton-Landis",
"url": "https://twitter.com/jitl"
},
{
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
},
{
"name": "Harrison Shoff",
"url": "https://twitter.com/hshoff"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/airbnb/javascript/issues"
},
"homepage": "https://github.com/airbnb/javascript",
"dependencies": {
"eslint-config-airbnb-base": "^5.0.1"
},
"devDependencies": {
"babel-eslint": "4.1.3",
"babel-tape-runner": "1.2.0",
"eslint": "1.5.1",
"eslint-plugin-react": "3.4.2",
"react": "0.13.3",
"tape": "4.2.0"
"babel-preset-airbnb": "^2.0.0",
"babel-tape-runner": "^2.0.1",
"eslint": "^3.2.2",
"eslint-find-rules": "^1.11.1",
"eslint-plugin-import": "^1.12.0",
"eslint-plugin-jsx-a11y": "^2.0.1",
"eslint-plugin-react": "^6.0.0",
"in-publish": "^2.0.0",
"react": ">= 0.13.0",
"tape": "^4.6.0"
},
"peerDependencies": {
"eslint": "^3.2.2",
"eslint-plugin-jsx-a11y": "^2.0.1",
"eslint-plugin-import": "^1.12.0",
"eslint-plugin-react": "^6.0.0"
},
"engines": {
"node": ">= 4"
}
}

View File

@@ -1,51 +0,0 @@
module.exports = {
'env': {
'es6': false
},
'ecmaFeatures': {
'arrowFunctions': true,
'blockBindings': true,
'classes': true,
'defaultParams': true,
'destructuring': true,
'forOf': true,
'generators': false,
'modules': true,
'objectLiteralComputedProperties': true,
'objectLiteralDuplicateProperties': false,
'objectLiteralShorthandMethods': true,
'objectLiteralShorthandProperties': true,
'spread': true,
'superInFunctions': true,
'templateStrings': true,
'jsx': true
},
'rules': {
// require parens in arrow function arguments
'arrow-parens': 0,
// require space before/after arrow function's arrow
'arrow-spacing': 0,
// verify super() callings in constructors
'constructor-super': 0,
// enforce the spacing around the * in generator functions
'generator-star-spacing': 0,
// disallow modifying variables of class declarations
'no-class-assign': 0,
// disallow modifying variables that are declared using const
'no-const-assign': 0,
// disallow to use this/super before super() calling in constructors.
'no-this-before-super': 0,
// require let or const instead of var
'no-var': 2,
// require method and property shorthand syntax for object literals
'object-shorthand': 0,
// suggest using of const declaration for variables that are never modified after declared
'prefer-const': 2,
// suggest using the spread operator instead of .apply()
'prefer-spread': 0,
// suggest using Reflect methods where applicable
'prefer-reflect': 0,
// disallow generator functions that do not have yield
'require-yield': 0
}
};

View File

@@ -1,16 +0,0 @@
module.exports = {
'rules': {
// specify the maximum depth that blocks can be nested
'max-depth': [0, 4],
// specify the maximum length of a line in your program
'max-len': [0, 80, 4],
// limits the number of parameters that can be used in the function declaration.
'max-params': [0, 3],
// specify the maximum number of statement allowed in a function
'max-statements': [0, 10],
// disallow use of bitwise operators
'no-bitwise': 0,
// disallow use of unary operators, ++ and --
'no-plusplus': 0
}
};

View File

@@ -0,0 +1,100 @@
module.exports = {
plugins: [
'jsx-a11y',
'react'
],
ecmaFeatures: {
jsx: true
},
rules: {
// Require ARIA roles to be valid and non-abstract
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
'jsx-a11y/aria-role': 2,
// Enforce all aria-* props are valid.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
'jsx-a11y/aria-props': 2,
// Enforce ARIA state and property values are valid.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
'jsx-a11y/aria-proptypes': 2,
// Enforce that elements that do not support ARIA roles, states, and
// properties do not have those attributes.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
'jsx-a11y/aria-unsupported-elements': 2,
// disallow href "#"
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md
'jsx-a11y/href-no-hash': [2, ['a']],
// Require <img> to have a non-empty `alt` prop, or role="presentation"
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md
'jsx-a11y/img-has-alt': 2,
// Prevent img alt text from containing redundant words like "image", "picture", or "photo"
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
'jsx-a11y/img-redundant-alt': 2,
// require that JSX labels use "htmlFor"
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
'jsx-a11y/label-has-for': [2, ['label']],
// require that mouseover/out come with focus/blur, for keyboard-only users
// TODO: evaluate
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
'jsx-a11y/mouse-events-have-key-events': 0,
// Prevent use of `accessKey`
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
'jsx-a11y/no-access-key': 2,
// require onBlur instead of onChange
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
'jsx-a11y/no-onchange': 0,
// Enforce that elements with onClick handlers must be focusable.
// TODO: evaluate
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-focus.md
'jsx-a11y/onclick-has-focus': 0,
// require things with onClick to have an aria role
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/onclick-has-role.md
'jsx-a11y/onclick-has-role': 0,
// Enforce that elements with ARIA roles must have all required attributes
// for that role.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
'jsx-a11y/role-has-required-aria-props': 2,
// Enforce that elements with explicit or implicit roles defined contain
// only aria-* properties supported by that role.
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
'jsx-a11y/role-supports-aria-props': 2,
// Enforce tabIndex value is not greater than zero.
// TODO: evaluate
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
'jsx-a11y/tabindex-no-positive': 0,
// ensure <hX> tags have content and are not aria-hidden
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
'jsx-a11y/heading-has-content': [2, ['']],
// require HTML elements to have a "lang" prop
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
'jsx-a11y/html-has-lang': 2,
// require HTML element's lang prop to be valid
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
'jsx-a11y/lang': 2,
// prevent marquee elements
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-marquee.md
'jsx-a11y/no-marquee': 2,
// only allow <th> to have the "scope" attr
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
'jsx-a11y/scope': 2,
},
};

View File

@@ -1,62 +1,259 @@
module.exports = {
'parser': 'babel-eslint',
'plugins': [
plugins: [
'react'
],
'ecmaFeatures': {
'jsx': true
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
'rules': {
ecmaFeatures: {
jsx: true
},
// View link below for react rules documentation
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
rules: {
// Specify whether double or single quotes should be used in JSX attributes
// http://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': [2, 'prefer-double'],
// Prevent missing displayName in a React component definition
'react/display-name': 0,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
'react/display-name': [0, { ignoreTranspilerName: false }],
// Forbid certain propTypes (any, array, object)
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
'react/forbid-prop-types': [0, { forbid: ['any', 'array', 'object'] }],
// Enforce boolean attributes notation in JSX
'react/jsx-boolean-value': 2,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
'react/jsx-boolean-value': [2, 'never'],
// Validate closing bracket location in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
'react/jsx-closing-bracket-location': [2, 'line-aligned'],
// Enforce or disallow spaces inside of curly braces in JSX attributes
'react/jsx-curly-spacing': 0,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
'react/jsx-curly-spacing': [2, 'never', { allowMultiline: true }],
// Enforce event handler naming conventions in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
'react/jsx-handler-names': [0, {
eventHandlerPrefix: 'handle',
eventHandlerPropPrefix: 'on',
}],
// Validate props indentation in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
'react/jsx-indent-props': [2, 2],
// Validate JSX has key prop when in array or iterator
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
'react/jsx-key': 0,
// Limit maximum of props on a single line in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
'react/jsx-max-props-per-line': [0, { maximum: 1 }],
// Prevent usage of .bind() in JSX props
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
'react/jsx-no-bind': [2, {
ignoreRefs: true,
allowArrowFunctions: true,
allowBind: false,
}],
// Prevent duplicate props in JSX
'react/jsx-no-duplicate-props': 0,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
'react/jsx-no-duplicate-props': [0, { ignoreCase: false }],
// Prevent usage of unwrapped JSX strings
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
'react/jsx-no-literals': 0,
// Disallow undeclared variables in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
'react/jsx-no-undef': 2,
// Enforce quote style for JSX attributes
'react/jsx-quotes': 0,
// Enforce PascalCase for user-defined JSX components
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
'react/jsx-pascal-case': [2, {
allowAllCaps: true,
ignore: [],
}],
// Enforce propTypes declarations alphabetical sorting
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
'react/sort-prop-types': [0, {
ignoreCase: false,
callbacksLast: false,
requiredFirst: false,
}],
// Deprecated in favor of react/jsx-sort-props
'react/jsx-sort-prop-types': 0,
// Enforce props alphabetical sorting
'react/jsx-sort-props': 0,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
'react/jsx-sort-props': [0, {
ignoreCase: false,
callbacksLast: false,
shorthandFirst: false,
shorthandLast: false,
}],
// Prevent React to be incorrectly marked as unused
'react/jsx-uses-react': 2,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
'react/jsx-uses-react': [2],
// Prevent variables used in JSX to be incorrectly marked as unused
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
'react/jsx-uses-vars': 2,
// Prevent usage of dangerous JSX properties
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md
'react/no-danger': 0,
// Prevent usage of deprecated methods
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
'react/no-deprecated': [2],
// Prevent usage of setState in componentDidMount
'react/no-did-mount-set-state': [2, 'allow-in-func'],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
'react/no-did-mount-set-state': [2],
// Prevent usage of setState in componentDidUpdate
'react/no-did-update-set-state': 2,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
'react/no-did-update-set-state': [2],
// Prevent direct mutation of this.state
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
'react/no-direct-mutation-state': 0,
// Prevent usage of isMounted
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
'react/no-is-mounted': 2,
// Prevent multiple component definition per file
'react/no-multi-comp': 2,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
'react/no-multi-comp': [2, { ignoreStateless: true }],
// Prevent usage of setState
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
'react/no-set-state': 0,
// Prevent using string references
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
'react/no-string-refs': 2,
// Prevent usage of unknown DOM property
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
'react/no-unknown-property': 2,
// Require ES6 class declarations over React.createClass
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
'react/prefer-es6-class': [2, 'always'],
// Require stateless functions when not using lifecycle methods, setState or ref
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
'react/prefer-stateless-function': 2,
// Prevent missing props validation in a React component definition
'react/prop-types': 2,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
'react/prop-types': [2, { ignore: [], customValidators: [] }],
// Prevent missing React when using JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
'react/react-in-jsx-scope': 2,
// Restrict file extensions that may be required
'react/require-extension': 0,
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md
'react/require-extension': [2, { extensions: ['.jsx', '.js'] }],
// Require render() methods to return something
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
'react/require-render-return': 2,
// Prevent extra closing tags for components without children
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
'react/self-closing-comp': 2,
// Enforce spaces before the closing bracket of self-closing JSX elements
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
'react/jsx-space-before-closing': [2, 'always'],
// Enforce component methods order
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md
'react/sort-comp': [2, {
'order': [
order: [
'static-methods',
'lifecycle',
'/^on.+$/',
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
'everything-else',
'/^render.+$/',
'render'
]
],
}],
// Prevent missing parentheses around multilines JSX
'react/wrap-multilines': 2
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
'react/jsx-wrap-multilines': [2, {
declaration: true,
assignment: true,
return: true
}],
'react/wrap-multilines': 0, // deprecated version
// Require that the first prop in a JSX element be on a new line when the element is multiline
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
'react/jsx-first-prop-new-line': [2, 'multiline'],
// Enforce spacing around jsx equals signs
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
'react/jsx-equals-spacing': [2, 'never'],
// Enforce JSX indentation
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
'react/jsx-indent': [2, 2],
// Disallow target="_blank" on links
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
'react/jsx-no-target-blank': 2,
// only .jsx files may have JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
'react/jsx-filename-extension': [2, { extensions: ['.jsx'] }],
// prevent accidental JS comments from being injected into JSX as text
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
'react/jsx-no-comment-textnodes': 2,
'react/no-comment-textnodes': 0, // deprecated version
// disallow using React.render/ReactDOM.render's return value
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
'react/no-render-return-value': 2,
// require a shouldComponentUpdate method, or PureRenderMixin
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
'react/require-optimization': [0, { allowDecorators: [] }],
// warn against using findDOMNode()
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
'react/no-find-dom-node': 2,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.json']
}
},
react: {
pragma: 'React',
version: '0.14'
},
}
};

View File

@@ -1,6 +0,0 @@
module.exports = {
'rules': {
// require that all functions are run in strict mode
'strict': [2, 'never']
}
};

View File

@@ -1,113 +0,0 @@
module.exports = {
'rules': {
// enforce spacing inside array brackets
'array-bracket-spacing': 0,
// enforce one true brace style
'brace-style': [2, '1tbs', {'allowSingleLine': true }],
// require camel case names
'camelcase': [2, {'properties': 'never'}],
// enforce spacing before and after comma
'comma-spacing': [2, {'before': false, 'after': true}],
// enforce one true comma style
'comma-style': [2, 'last'],
// require or disallow padding inside computed properties
'computed-property-spacing': 0,
// enforces consistent naming when capturing the current execution context
'consistent-this': 0,
// enforce newline at the end of file, with no multiple empty lines
'eol-last': 2,
// require function expressions to have a name
'func-names': 1,
// enforces use of function declarations or expressions
'func-style': 0,
// this option enforces minimum and maximum identifier lengths (variable names, property names etc.)
'id-length': [2, {'min': 2, 'properties': 'never'}],
// this option sets a specific tab width for your code
'indent': [2, 2],
// specify whether double or single quotes should be used in JSX attributes
'jsx-quotes': 2,
// enforces spacing between keys and values in object literal properties
'key-spacing': [2, {'beforeColon': false, 'afterColon': true}],
// enforces empty lines around comments
'lines-around-comment': 0,
// disallow mixed 'LF' and 'CRLF' as linebreaks
'linebreak-style': 0,
// specify the maximum depth callbacks can be nested
'max-nested-callbacks': 0,
// require a capital letter for constructors
'new-cap': [2, {'newIsCap': true}],
// disallow the omission of parentheses when invoking a constructor with no arguments
'new-parens': 0,
// allow/disallow an empty newline after var statement
'newline-after-var': 0,
// disallow use of the Array constructor
'no-array-constructor': 0,
// disallow use of the continue statement
'no-continue': 0,
// disallow comments inline after code
'no-inline-comments': 0,
// disallow if as the only statement in an else block
'no-lonely-if': 0,
// disallow mixed spaces and tabs for indentation
'no-mixed-spaces-and-tabs': 0,
// disallow multiple empty lines
'no-multiple-empty-lines': [2, {'max': 2}],
// disallow nested ternary expressions
'no-nested-ternary': 2,
// disallow use of the Object constructor
'no-new-object': 2,
// disallow space between function identifier and application
'no-spaced-func': 2,
// disallow the use of ternary operators
'no-ternary': 0,
// disallow trailing whitespace at the end of lines
'no-trailing-spaces': 2,
// disallow dangling underscores in identifiers
'no-underscore-dangle': 0,
// disallow the use of Boolean literals in conditional expressions
'no-unneeded-ternary': 0,
// require or disallow padding inside curly braces
'object-curly-spacing': 0,
// allow just one var statement per function
'one-var': [2, 'never'],
// require assignment operator shorthand where possible or prohibit it entirely
'operator-assignment': 0,
// enforce operators to be placed before or after line breaks
'operator-linebreak': 0,
// enforce padding within blocks
'padded-blocks': [2, 'never'],
// require quotes around object literal property names
'quote-props': 0,
// specify whether double or single quotes should be used
'quotes': [2, 'single', 'avoid-escape'],
// require identifiers to match the provided regular expression
'id-match': 0,
// enforce spacing before and after semicolons
'semi-spacing': [2, {'before': false, 'after': true}],
// require or disallow use of semicolons instead of ASI
'semi': [2, 'always'],
// sort variables within the same declaration block
'sort-vars': 0,
// require a space after certain keywords
'space-after-keywords': 2,
// require or disallow space before blocks
'space-before-blocks': 2,
// require or disallow space before function opening parenthesis
'space-before-function-paren': [2, 'never'],
// require or disallow spaces inside parentheses
'space-in-parens': 0,
// require spaces around operators
'space-infix-ops': 2,
// require a space after return, throw, and case
'space-return-throw-case': 2,
// Require or disallow spaces before/after unary operators
'space-unary-ops': 0,
// require or disallow a space immediately following the // or /* in a comment
'spaced-comment': [2, 'always', {
'exceptions': ['-', '+'],
'markers': ['=', '!'] // space here to support sprockets directives
}],
// require regex literals to be wrapped in parentheses
'wrap-regex': 0
}
};

View File

@@ -3,7 +3,11 @@
// disabled because I find it tedious to write tests while following this
// rule
"no-shadow": 0,
// tests uses `t` for tape
"id-length": [2, {"min": 2, "properties": "never", "exceptions": ["t"]}]
"id-length": [2, {"min": 2, "properties": "never", "exceptions": ["t"]}],
// tests can import things in devDependencies
"import/no-extraneous-dependencies": [2, {"devDependencies": true}]
}
}

View File

@@ -2,16 +2,16 @@ import fs from 'fs';
import path from 'path';
import test from 'tape';
const files = {
base: require('../base')
};
const base = require('../base');
const files = { base };
fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => {
if (name === 'react.js') {
if (name === 'react.js' || name === 'react-a11y.js') {
return;
}
files[name] = require(`../rules/${name}`);
files[name] = require(`../rules/${name}`); // eslint-disable-line global-require
});
Object.keys(files).forEach(name => {
@@ -20,7 +20,10 @@ Object.keys(files).forEach(name => {
test(`${name}: does not reference react`, t => {
t.plan(2);
t.notOk(config.plugins, 'plugins is unspecified');
// scan plugins for react and fail if it is found
const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins') &&
config.plugins.indexOf('react') !== -1;
t.notOk(hasReactPlugin, 'there is no react plugin');
// scan rules for react/ and fail if any exist
const reactRuleIds = Object.keys(config.rules)

View File

@@ -1,40 +1,45 @@
import test from 'tape';
import { CLIEngine } from 'eslint';
import eslintrc from '../';
import baseConfig from '../base';
import reactRules from '../rules/react';
import reactA11yRules from '../rules/react-a11y';
const cli = new CLIEngine({
useEslintrc: false,
baseConfig: eslintrc,
// This rule fails when executing on text.
rules: {indent: 0},
rules: {
// It is okay to import devDependencies in tests.
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
},
});
function lint(text) {
// @see http://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles
// @see http://eslint.org/docs/developer-guide/nodejs-api.html#executeontext
return cli.executeOnText(text).results[0];
const linter = cli.executeOnText(text);
return linter.results[0];
}
function wrapComponent(body) {
return `
import React from 'react';
export default class MyComponent extends React.Component {
/* eslint no-empty-function: 0 */
${body}
}
`;
}
test('validate react prop order', t => {
t.test('make sure our eslintrc has React linting dependencies', t => {
test('validate react prop order', (t) => {
t.test('make sure our eslintrc has React and JSX linting dependencies', (t) => {
t.plan(2);
t.equal(baseConfig.parser, 'babel-eslint', 'uses babel-eslint');
t.equal(reactRules.plugins[0], 'react', 'uses eslint-plugin-react');
t.deepEqual(reactRules.plugins, ['react']);
t.deepEqual(reactA11yRules.plugins, ['jsx-a11y', 'react']);
});
t.test('passes a good component', t => {
t.test('passes a good component', (t) => {
t.plan(3);
const result = lint(wrapComponent(`
componentWillMount() {}

View File

@@ -5,54 +5,82 @@
## Table of Contents
1. [Basic Rules](#basic-rules)
1. [Class vs `React.createClass` vs stateless](#class-vs-reactcreateclass-vs-stateless)
1. [Naming](#naming)
1. [Declaration](#declaration)
1. [Alignment](#alignment)
1. [Quotes](#quotes)
1. [Spacing](#spacing)
1. [Props](#props)
1. [Refs](#refs)
1. [Parentheses](#parentheses)
1. [Tags](#tags)
1. [Methods](#methods)
1. [Ordering](#ordering)
1. [`isMounted`](#ismounted)
## Basic Rules
- Only include one React component per file.
- However, multiple [Stateless, or Pure, Components](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) are allowed per file. eslint: [`react/no-multi-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md#ignorestateless).
- Always use JSX syntax.
- Do not use `React.createElement` unless you're initializing the app from a file that is not JSX.
## Class vs React.createClass
## Class vs `React.createClass` vs stateless
- Use class extends React.Component unless you have a very good reason to use mixins.
- If you have internal state and/or refs, prefer `class extends React.Component` over `React.createClass` unless you have a very good reason to use mixins. eslint: [`react/prefer-es6-class`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md) [`react/prefer-stateless-function`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md)
```javascript
// bad
const Listing = React.createClass({
render() {
return <div />;
```jsx
// bad
const Listing = React.createClass({
// ...
render() {
return <div>{this.state.hello}</div>;
}
});
// good
class Listing extends React.Component {
// ...
render() {
return <div>{this.state.hello}</div>;
}
}
});
// good
class Listing extends React.Component {
render() {
return <div />;
```
And if you don't have state or refs, prefer normal functions (not arrow functions) over classes:
```jsx
// bad
class Listing extends React.Component {
render() {
return <div>{this.props.hello}</div>;
}
}
}
```
// bad (relying on function name inference is discouraged)
const Listing = ({ hello }) => (
<div>{hello}</div>
);
// good
function Listing({ hello }) {
return <div>{hello}</div>;
}
```
## Naming
- **Extensions**: Use `.jsx` extension for React components.
- **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.jsx`.
- **Reference Naming**: Use PascalCase for React components and camelCase for their instances:
```javascript
- **Reference Naming**: Use PascalCase for React components and camelCase for their instances. eslint: [`react/jsx-pascal-case`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md)
```jsx
// bad
const reservationCard = require('./ReservationCard');
import reservationCard from './ReservationCard';
// good
const ReservationCard = require('./ReservationCard');
import ReservationCard from './ReservationCard';
// bad
const ReservationItem = <ReservationCard />;
@@ -61,23 +89,49 @@
const reservationItem = <ReservationCard />;
```
**Component Naming**: Use the filename as the component name. For example, `ReservationCard.jsx` should have a reference name of `ReservationCard`. However, for root components of a directory, use `index.jsx` as the filename and use the directory name as the component name:
```javascript
- **Component Naming**: Use the filename as the component name. For example, `ReservationCard.jsx` should have a reference name of `ReservationCard`. However, for root components of a directory, use `index.jsx` as the filename and use the directory name as the component name:
```jsx
// bad
const Footer = require('./Footer/Footer.jsx')
import Footer from './Footer/Footer';
// bad
const Footer = require('./Footer/index.jsx')
import Footer from './Footer/index';
// good
const Footer = require('./Footer')
import Footer from './Footer';
```
- **Higher-order Component Naming**: Use a composite of the higher-order component's name and the passed-in component's name as the `displayName` on the generated component. For example, the higher-order component `withFoo()`, when passed a component `Bar` should produce a component with a `displayName` of `withFoo(Bar)`.
> Why? A component's `displayName` may be used by developer tools or in error messages, and having a value that clearly expresses this relationship helps people understand what is happening.
```jsx
// bad
export default function withFoo(WrappedComponent) {
return function WithFoo(props) {
return <WrappedComponent {...props} foo />;
}
}
// good
export default function withFoo(WrappedComponent) {
function WithFoo(props) {
return <WrappedComponent {...props} foo />;
}
const wrappedComponentName = WrappedComponent.displayName
|| WrappedComponent.name
|| 'Component';
WithFoo.displayName = `withFoo(${wrappedComponentName})`;
return WithFoo;
}
```
## Declaration
- Do not use displayName for naming components. Instead, name the component by reference.
```javascript
- Do not use `displayName` for naming components. Instead, name the component by reference.
```jsx
// bad
export default React.createClass({
displayName: 'ReservationCard',
@@ -90,9 +144,10 @@
```
## Alignment
- Follow these alignment styles for JSX syntax
```javascript
- Follow these alignment styles for JSX syntax. eslint: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md)
```jsx
// bad
<Foo superLongParam="bar"
anotherSuperLongParam="baz" />
@@ -111,13 +166,18 @@
superLongParam="bar"
anotherSuperLongParam="baz"
>
<Spazz />
<Quux />
</Foo>
```
## Quotes
- Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS.
```javascript
- Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS. eslint: [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes)
> Why? JSX attributes [can't contain escaped quotes](http://eslint.org/docs/rules/jsx-quotes), so double quotes make contractions like `"don't"` easier to type.
> Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention.
```jsx
// bad
<Foo bar='bar' />
@@ -132,8 +192,10 @@
```
## Spacing
- Always include a single space in your self-closing tag.
```javascript
```jsx
// bad
<Foo/>
@@ -148,9 +210,21 @@
<Foo />
```
- Do not pad JSX curly braces with spaces. eslint: [`react/jsx-curly-spacing`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md)
```jsx
// bad
<Foo bar={ baz } />
// good
<Foo bar={baz} />
```
## Props
- Always use camelCase for prop names.
```javascript
```jsx
// bad
<Foo
UserName="hello"
@@ -164,10 +238,115 @@
/>
```
- Omit the value of the prop when it is explicitly `true`. eslint: [`react/jsx-boolean-value`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md)
```jsx
// bad
<Foo
hidden={true}
/>
// good
<Foo
hidden
/>
```
- Always include an `alt` prop on `<img>` tags. If the image is presentational, `alt` can be an empty string or the `<img>` must have `role="presentation"`. eslint: [`jsx-a11y/img-has-alt`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md)
```jsx
// bad
<img src="hello.jpg" />
// good
<img src="hello.jpg" alt="Me waving hello" />
// good
<img src="hello.jpg" alt="" />
// good
<img src="hello.jpg" role="presentation" />
```
- Do not use words like "image", "photo", or "picture" in `<img>` `alt` props. eslint: [`jsx-a11y/img-redundant-alt`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md)
> Why? Screenreaders already announce `img` elements as images, so there is no need to include this information in the alt text.
```jsx
// bad
<img src="hello.jpg" alt="Picture of me waving hello" />
// good
<img src="hello.jpg" alt="Me waving hello" />
```
- Use only valid, non-abstract [ARIA roles](https://www.w3.org/TR/wai-aria/roles#role_definitions). eslint: [`jsx-a11y/aria-role`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md)
```jsx
// bad - not an ARIA role
<div role="datepicker" />
// bad - abstract ARIA role
<div role="range" />
// good
<div role="button" />
```
- Do not use `accessKey` on elements. eslint: [`jsx-a11y/no-access-key`](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md)
> Why? Inconsistencies between keyboard shortcuts and keyboard commands used by people using screenreaders and keyboards complicate accessibility.
```jsx
// bad
<div accessKey="h" />
// good
<div />
```
- Avoid using an array index as `key` prop, prefer a unique ID. ([why?](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318))
```jsx
// bad
{todos.map((todo, index) =>
<Todo
{...todo}
key={index}
/>
)}
// good
{todos.map(todo => (
<Todo
{...todo}
key={todo.id}
/>
))}
```
## Refs
- Always use ref callbacks. eslint: [`react/no-string-refs`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md)
```jsx
// bad
<Foo
ref="myRef"
/>
// good
<Foo
ref={(ref) => this.myRef = ref}
/>
```
## Parentheses
- Wrap JSX tags in parentheses when they span more than one line:
```javascript
/// bad
- Wrap JSX tags in parentheses when they span more than one line. eslint: [`react/wrap-multilines`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md)
```jsx
// bad
render() {
return <MyComponent className="long body" foo="bar">
<MyChild />
@@ -191,8 +370,10 @@
```
## Tags
- Always self-close tags that have no children.
```javascript
- Always self-close tags that have no children. eslint: [`react/self-closing-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md)
```jsx
// bad
<Foo className="stuff"></Foo>
@@ -200,8 +381,9 @@
<Foo className="stuff" />
```
- If your component has multi-line properties, close its tag on a new line.
```javascript
- If your component has multi-line properties, close its tag on a new line. eslint: [`react/jsx-closing-bracket-location`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md)
```jsx
// bad
<Foo
bar="bar"
@@ -215,13 +397,66 @@
```
## Methods
- Use arrow functions to close over local variables.
```jsx
function ItemList(props) {
return (
<ul>
{props.items.map((item, index) => (
<Item
key={item.key}
onClick={() => doSomethingWith(item.name, index)}
/>
))}
</ul>
);
}
```
- Bind event handlers for the render method in the constructor. eslint: [`react/jsx-no-bind`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md)
> Why? A bind call in the render path creates a brand new function on every single render.
```jsx
// bad
class extends React.Component {
onClickDiv() {
// do stuff
}
render() {
return <div onClick={this.onClickDiv.bind(this)} />
}
}
// good
class extends React.Component {
constructor(props) {
super(props);
this.onClickDiv = this.onClickDiv.bind(this);
}
onClickDiv() {
// do stuff
}
render() {
return <div onClick={this.onClickDiv} />
}
}
```
- Do not use underscore prefix for internal methods of a React component.
```javascript
```jsx
// bad
React.createClass({
_onClickSubmit() {
// do stuff
}
},
// other stuff
});
@@ -233,79 +468,112 @@
}
// other stuff
});
}
```
- Be sure to return a value in your `render` methods. eslint: [`require-render-return`](https://github.com/yannickcr/eslint-plugin-react/pull/502)
```jsx
// bad
render() {
(<div />);
}
// good
render() {
return (<div />);
}
```
## Ordering
- Ordering for class extends React.Component:
1. constructor
1. optional static methods
1. getChildContext
1. componentWillMount
1. componentDidMount
1. componentWillReceiveProps
1. shouldComponentUpdate
1. componentWillUpdate
1. componentDidUpdate
1. componentWillUnmount
1. *clickHandlers or eventHandlers* like onClickSubmit() or onChangeDescription()
1. *getter methods for render* like getSelectReason() or getFooterContent()
1. *Optional render methods* like renderNavigation() or renderProfilePicture()
1. render
- Ordering for `class extends React.Component`:
- How to define propTypes, defaultProps, contextTypes, etc...
1. optional `static` methods
1. `constructor`
1. `getChildContext`
1. `componentWillMount`
1. `componentDidMount`
1. `componentWillReceiveProps`
1. `shouldComponentUpdate`
1. `componentWillUpdate`
1. `componentDidUpdate`
1. `componentWillUnmount`
1. *clickHandlers or eventHandlers* like `onClickSubmit()` or `onChangeDescription()`
1. *getter methods for `render`* like `getSelectReason()` or `getFooterContent()`
1. *Optional render methods* like `renderNavigation()` or `renderProfilePicture()`
1. `render`
```javascript
import React, { Component, PropTypes } from 'react';
const propTypes = {
id: PropTypes.number.isRequired,
url: PropTypes.string.isRequired,
text: PropTypes.string,
};
const defaultProps = {
text: 'Hello World',
};
export default class Link extends Component {
static methodsAreOk() {
return true;
- How to define `propTypes`, `defaultProps`, `contextTypes`, etc...
```jsx
import React, { PropTypes } from 'react';
const propTypes = {
id: PropTypes.number.isRequired,
url: PropTypes.string.isRequired,
text: PropTypes.string,
};
const defaultProps = {
text: 'Hello World',
};
class Link extends React.Component {
static methodsAreOk() {
return true;
}
render() {
return <a href={this.props.url} data-id={this.props.id}>{this.props.text}</a>
}
}
render() {
return <a href={this.props.url} data-id={this.props.id}>{this.props.text}</a>
}
}
Link.propTypes = propTypes;
Link.defaultProps = defaultProps;
```
- Ordering for React.createClass:
Link.propTypes = propTypes;
Link.defaultProps = defaultProps;
1. displayName
1. propTypes
1. contextTypes
1. childContextTypes
1. mixins
1. statics
1. defaultProps
1. getDefaultProps
1. getInitialState
1. getChildContext
1. componentWillMount
1. componentDidMount
1. componentWillReceiveProps
1. shouldComponentUpdate
1. componentWillUpdate
1. componentDidUpdate
1. componentWillUnmount
1. *clickHandlers or eventHandlers* like onClickSubmit() or onChangeDescription()
1. *getter methods for render* like getSelectReason() or getFooterContent()
1. *Optional render methods* like renderNavigation() or renderProfilePicture()
1. render
export default Link;
```
- Ordering for `React.createClass`: eslint: [`react/sort-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md)
1. `displayName`
1. `propTypes`
1. `contextTypes`
1. `childContextTypes`
1. `mixins`
1. `statics`
1. `defaultProps`
1. `getDefaultProps`
1. `getInitialState`
1. `getChildContext`
1. `componentWillMount`
1. `componentDidMount`
1. `componentWillReceiveProps`
1. `shouldComponentUpdate`
1. `componentWillUpdate`
1. `componentDidUpdate`
1. `componentWillUnmount`
1. *clickHandlers or eventHandlers* like `onClickSubmit()` or `onChangeDescription()`
1. *getter methods for `render`* like `getSelectReason()` or `getFooterContent()`
1. *Optional render methods* like `renderNavigation()` or `renderProfilePicture()`
1. `render`
## `isMounted`
- Do not use `isMounted`. eslint: [`react/no-is-mounted`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md)
> Why? [`isMounted` is an anti-pattern][anti-pattern], is not available when using ES6 classes, and is on its way to being officially deprecated.
[anti-pattern]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
## Translation
This JSX/React style guide is also available in other languages:
- ![cn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/China.png) **Chinese (Simplified)**: [JasonBoy/javascript](https://github.com/JasonBoy/javascript/tree/master/react)
- ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polish**: [pietraszekl/javascript](https://github.com/pietraszekl/javascript/tree/master/react)
- ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [apple77y/javascript](https://github.com/apple77y/javascript/tree/master/react)
- ![Br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Portuguese**: [ronal2do/javascript](https://github.com/ronal2do/airbnb-react-styleguide)
**[⬆ back to top](#table-of-contents)**