Compare commits

...

941 Commits

Author SHA1 Message Date
Jordan Harband
0f3ca32323 [eslint config] [*] [deps] update object.entries 2023-05-15 10:21:09 -07:00
Jordan Harband
95b6b43d63 [eslint-config] [*] [dev deps] update @babel/runtime 2023-05-15 10:20:15 -07:00
Jordan Harband
240a3789db [Dev Deps] update markdownlint, markdownlint-cli 2023-05-15 10:19:05 -07:00
Jordan Harband
0e627e2fa3 [readme] update eslint plugin repo URLs 2023-05-15 10:15:59 -07:00
Christian Koop
7982931ba7 [readme] Updates ESLint rule in section 12.3 (exponentiation-operator)
The change itself has already been made in f3d3a075cd
(tracked in/acording to https://github.com/airbnb/javascript/issues/2421#issuecomment-1371305010).


#2421
Remove Math.pow from `no-restricted-properties` and use `prefer-exponentiation-operator` instead.
2023-05-02 19:49:09 +02:00
Felipe Garcia Diaz
69fc1bf195 spell checking, fixed grammar error. 2023-04-28 03:33:28 -04:00
syedmouaazfarrukh
5c01a10949 [readme] added JavaScript Roadmap link 2023-02-07 11:17:51 -08:00
Jordan Harband
bf536566ce [eslint config] [deps] update eslint-plugin-react, eslint-plugin-jsx-a11y 2023-02-08 22:59:18 -08:00
Jordan Harband
917c8d92a3 [*] [deps] update eslint-plugin-import 2023-02-08 22:19:53 -08:00
Jordan Harband
8091e39343 [*] [dev deps] update @babel/runtime, tape 2023-02-08 22:11:42 -08:00
Jordan Harband
fd96a4fd57 [eslint config] [*] [refactor] use object spread instead of Object.assign 2022-12-30 14:48:36 -08:00
Mustafa UZUN
81157eec23 [guide] add Object.hasOwn 2022-11-17 20:15:09 +03:00
Mert Can Altın
4ef69edc63 [Tests] refactor test paths 2022-12-04 00:32:01 +03:00
Mustafa UZUN
d601701730 [readme] wayback machine, or remove, broken links 2022-10-30 02:00:29 +03:00
Mustafa UZUN
49d08a2f13 [readme] prefer const/let over var in examples
2.1 Use const for all of your references; avoid using var. eslint: prefer-const, no-const-assign
2022-10-29 23:49:43 +03:00
Pushpendra Pal
0d747c6d96 [readme] add space before code blocks 2022-11-14 04:54:20 +05:30
Jordan Harband
1fb7d76add [eslint config] [patch] add new disabled core rules 2022-11-17 13:56:33 -08:00
Maksim Ploski
38f1488918 [guide] fix typo in space-before-blocks 2022-10-31 21:57:59 +03:00
Mustafa UZUN
c6b1a43c48 [guide] rename qux to quux
Fixes #2661
2022-10-26 13:44:17 +03:00
Mustafa UZUN
6947138ee3 [guide] add comma to the end of the property 2022-10-26 16:17:38 +03:00
Mustafa UZUN
6fb4f8e878 [guide] add Optional Chaining 2022-10-26 00:06:26 +03:00
Mustafa UZUN
ca0ff97f17 [guide] add Nullish Coalescing operator 2022-10-25 23:26:56 +03:00
Mustafa UZUN
0b1f62372e [editorial] convert example to use single instead of double quotes 2022-10-25 16:03:37 +03:00
Jordan Harband
7dbb7b154f [eslint config] [base] add disabled logical-assignment-operators rule 2022-10-25 09:42:25 -07:00
Jordan Harband
75a908aacf [eslint config] [deps] update eslint-plugin-jsx-a11y, eslint-plugin-react, eslint-plugin-react-hooks 2022-09-18 22:21:48 -07:00
Jordan Harband
f6f63b89f6 [eslint config] [*] [deps] update object.assign 2022-09-18 22:18:57 -07:00
Jordan Harband
866f441d05 [eslint config] [*] update @babel/runtime, tape 2022-09-18 22:18:17 -07:00
Jordan Harband
5143a7a97a [Dev Deps] update markdownlint, markdownlint-cli 2022-09-18 22:16:08 -07:00
Jordan Harband
3cbf96de7c [eslint config] [base] no-alert: add TODO comment 2022-09-18 22:08:04 -07:00
Haoqun Jiang
5155aa5fc1 [eslint config] [base] disable the deprecated no-spaced-func rule
This rule was deprecated since ESLint v3.3.0 and replaced by the
`func-call-spacing` rule.
https://eslint.org/docs/latest/rules/no-spaced-func

`func-call-spacing` was enabled in this package long ago:
27dcb99c6d

So there's no need for it to stay in the ruleset.

Besides, it is causing some tricky issues when overriding the rules for
TypeScript support (https://github.com/iamturns/eslint-config-airbnb-typescript/issues/246)
2022-08-08 21:56:10 +08:00
Michael Orzel
cbf9ade10a [guide] Added period to 4.4 for formatting consistency. 2021-07-02 09:40:46 -04:00
Jordan Harband
206d25b55a [eslint config] [deps] update eslint-plugin-react 2022-05-24 08:52:07 -07:00
Jordan Harband
a0e94052d5 [eslint config] [*] [dev deps] update @babel/runtime 2022-05-24 08:49:47 -07:00
Joe Lencioni
42c0e2ea13 Fix typo in eslint-config-airbnb-base changelog 2022-05-24 09:52:05 -05:00
terrablue
7fdc87a8be [guide] fix eslint core rule URLs
- fix broken eslint eol-last link
 - remove .html ending in eslint urls
2022-05-03 19:06:48 +02:00
Jordan Harband
1677ba6c6a [eslint config] [meta] update eslint-plugin-react repo URLs 2022-05-03 10:41:03 -07:00
Jordan Harband
7c0f28af8b [eslint config] [deps] update @babel/runtime, eslint-find-rules, eslint-plugin-import, eslint-plugin-react, eslint-plugin-react-hooks, tape 2022-05-03 10:33:40 -07:00
Jordan Harband
fd2f5a1dae [eslint config] [base] [deps] update @babel/runtime, confusing-browser-globals, eslint-find-rules, eslint-plugin-import, tape 2022-05-03 10:29:37 -07:00
Jordan Harband
b4377fb030 [meta] better eclint command 2022-01-11 12:09:40 -08:00
Jordan Harband
34b5bc39f1 [meta] revert changes from d4e39c9b10
Caused by https://github.com/npm/cli/issues/3619
2021-12-25 12:34:37 -08:00
Jordan Harband
d4e39c9b10 v19.0.4 2021-12-25 07:34:29 -08:00
Jordan Harband
baaa5e8d26 [eslint config] v19.0.3 2021-12-24 12:27:19 -08:00
David Petersen
274c8d5701 [eslint config] [patch] set namedComponents option to match style guide
Change the `namedComponents` option to `function-declaration` to match what the style guide requires.

019e0f7e07 (r60060792)
2021-11-10 17:05:21 -06:00
Jordan Harband
38bc026fe4 [eslint config] [base] add disabled prefer-object-has-own rule 2021-12-22 15:12:04 -08:00
Jordan Harband
445322db64 [eslint config] [deps] update eslint-plugin-react 2021-12-22 15:09:25 -08:00
Jordan Harband
152bd5e85a [eslint config] v19.0.2 2021-12-02 10:34:58 -08:00
Jordan Harband
afc2cc3432 [eslint config] [meta] fix "exports" path
Fixes #2524
2021-12-02 10:04:51 -08:00
Jordan Harband
371537f393 [Tests] re-enable tests disabled for the eslint 8 upgrade 2021-11-22 13:44:36 -08:00
Jordan Harband
c05ffb2417 [eslint config] v19.0.1 2021-11-22 13:32:11 -08:00
Jordan Harband
97a3238020 [eslint config] [deps] update eslint-plugin-react 2021-11-22 11:12:36 -08:00
Jordan Harband
e0bb393519 [eslint config] [*] [dev deps] update tape 2021-11-22 11:12:26 -08:00
Jordan Harband
c4000b932a [eslint config] [fix] whitespace: udpate to support eslint 8
Fixes #2517
2021-11-22 11:07:00 -08:00
Jordan Harband
31c6f21878 [eslint config] [base] [refactor] make a single source of truth for whitespace rule names 2021-11-22 11:06:19 -08:00
Yatin
91cab81f69 [readme] operator => parameter syntax 2021-11-17 00:14:08 +05:30
d8cb404da7 [eslint config] [base] remove unneeded eslint version check 2021-11-11 23:45:40 +08:00
Jordan Harband
52e710c14e [eslint config] v19.0.0 2021-11-10 12:25:30 -08:00
Jordan Harband
1bc8cabd44 [eslint config] [breaking] support eslint 8; drop eslint < 7 2021-11-10 11:31:18 -08:00
Jordan Harband
37ebbba44c [eslint config] [deps] update eslint-config-airbnb-base, eslint-plugin-jsx-a11y, eslint-plugin-react, eslint-plugin-react-hooks, safe-publish-latest 2021-11-10 00:04:12 -08:00
Jordan Harband
930a6f2e4c [eslint config] [*] update @babel/runtime, eslint-plugin-import 2021-11-10 00:01:04 -08:00
Jordan Harband
366bfa6638 [eslint config] [base] v15.0.0 2021-11-08 22:59:44 -08:00
Jordan Harband
f3d3a075cd [eslint config] [base] [breaking] drop eslint < 7, add eslint 8 2021-11-08 18:27:29 -08:00
Jordan Harband
eac8cc605b [eslint config] [base] [breaking] add exports 2021-11-08 18:48:04 -08:00
Jordan Harband
be6966b251 [eslint-config] [meta] add --no-save to link scripts 2021-11-08 22:33:12 -08:00
Jordan Harband
4fc997b97e [readme] some updates 2021-11-08 18:42:02 -08:00
Jordan Harband
96f11d8c81 [actions] run prepublishOnly in prepublish tests 2021-11-08 22:25:39 -08:00
Jordan Harband
c12a08c479 [actions] fix action working directories 2021-11-08 18:27:29 -08:00
Jordan Harband
10a6d02c66 [meta] use prepublishOnly script for npm 7+ 2021-11-08 21:21:58 -08:00
Jordan Harband
ef6c478a2b [eslint config] [*] [dev deps] update @babel/runtime 2021-11-08 18:06:45 -08:00
Jordan Harband
6734b78911 [eslint config] [*] [deps] update eslint-plugin-import, object.entries 2021-11-08 16:00:07 -08:00
Kai
fdc812a0a5 [Docs] HTTP => HTTPS 2021-11-04 00:24:41 +01:00
Joe Lencioni
8aec65a4d3 Merge pull request #2491 from airbnb/travis
[Tests] migrate tests to Github Actions
2021-11-05 12:49:19 -05:00
Jordan Harband
ea5b991a4f [Tests] migrate tests to Github Actions 2021-11-04 23:05:04 -07:00
Augustus Buonviri
2a6bec1132 [eslint config] [base] [patch] Improve function-paren-newline with multiline-arguments option
Related to #1731

Co-authored-by: Augustus Buonviri <augustus.buonviri@stratusgrid.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2021-09-14 22:12:31 -04:00
Johnwesley R
82dbec3c99 [guide] Fix 14.1 Temporal Dead Zones link 2021-10-17 14:27:43 -04:00
Mustafa Haddara
122788230a [eslint config] clarify hooks requirement 2021-10-15 17:00:15 -04:00
Marko Schulz
4ee7326393 [eslint-config-airbnb] [patch] Explain why react/jsx-key is turned off 2021-09-24 11:26:03 +02:00
Jordan Harband
7fbed3b55c [eslint-config-airbnb] [deps] update eslint-plugin-react 2021-09-28 21:44:21 -07:00
Jordan Harband
30927d2503 [*] [deps] update @babel/runtime, eslint-plugin-import, tape 2021-09-28 21:41:06 -07:00
Luke Ingalls
f5c14cae2f [readme] fixed typo and removed redundancy 2021-06-18 19:49:13 -06:00
Jordan Harband
428c9ddb7e [*] [deps] update @babel/runtime, eslint-plugin-import, eslint-plugin-react 2021-06-29 10:03:15 -07:00
Jordan Harband
af8bdf17dd [*] [deps] update object.entries 2021-06-29 09:56:18 -07:00
amirvatani
d5d406a849 [readme] add AloPeyk to "in the wild" 2021-05-09 00:10:31 -07:00
Asher Hwang
35914b1402 [guide] Spread operator => Spread syntax 2021-05-11 09:08:23 +09:00
Kiran S
1fb4592122 [guide] add references for eslint rules 2021-05-04 21:15:46 +05:30
Kushang Shah
5641278fa1 [editorial] add var info to let/const section 2021-05-03 16:34:19 -07:00
Kiran S
dc3af3a90e [eslint config] [base] update default value for complexity 2021-05-03 21:39:00 +05:30
Mackenzie Morgan
1eadb93e37 [eslint config] [fix] bump eslint-plugin-react-hooks peer dependency version
Fixes #2355
2020-12-17 00:18:29 -05:00
Cong Zhang
0cf78acab0 [guide] Fix 19.6 example code 2021-03-24 18:17:15 +08:00
Diane Ko
730b749274 [eslint config] [patch] Alphabetize the rules for react-a11y.js
The ordering of the rules are currently not alphabetical, which can make it hard to tell whether there are rules missing or what's set for each rule from eslint-plugin-jsx-a11y.

This change alphabetizes the list so it's easier to compare to the [list of supported rules](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
2021-03-24 18:38:08 -07:00
Jordan Harband
4d837646b7 [eslint config] [deps] update eslint-plugin-react 2021-03-24 23:33:38 -07:00
Jordan Harband
1b540ba14e [*] [dev deps] update tape 2021-03-24 23:32:41 -07:00
kimhanui
711aeb650d [editorial] Complete 19.6 example code (cut in the middle)
Fixes #2403
2021-03-18 08:43:41 +09:00
Ikko Ashimine
9c181108a7 [meta] Fix typo in .markdownlint.json
preceeding -> preceding
2021-01-08 20:40:02 +09:00
marsonya
ea5ec0c524 [readme] removed dead links - 404 not found 2020-12-30 10:44:32 +05:30
Jordan Harband
db8b6ceb33 [eslint config] update eslint-plugin-react, add new rules, disabled 2020-12-29 21:37:48 -08:00
Jordan Harband
b9ff0aee71 [eslint-config] [base] add disabled no-unsafe-optional-chaining rule 2020-12-29 21:34:18 -08:00
Jordan Harband
fb3214c9d6 [*] [deps] update object.entries 2020-12-29 21:32:29 -08:00
Jordan Harband
66cd156a48 [*] [dev deps] update tape 2020-12-29 21:32:08 -08:00
Hollow Man
63098cbb6c [eslint config] [base] [patch] arthmetic -> arithmetic 2020-11-20 22:49:57 +08:00
Jeremy
1f786e154f [eslint config] [base] [patch] fix spelling of "than"
you mean "than" not "then".
2020-11-11 20:17:20 -06:00
Jordan Harband
5620bd5620 [eslint config] [base] add no-nonoctal-decimal-escape rule 2020-11-21 00:59:24 -08:00
Hugo Alliaume
f0df3a8680 [eslint config] [base] import/no-extraneous-dependencies: Add .eslintrc.js to devDeps
Similar to #1168 and #1522.
2020-11-07 08:17:29 +01:00
Jordan Harband
37d48dbf60 [eslint config] v18.2.1 2020-11-06 14:20:24 -08:00
Jordan Harband
e5de51e55f [eslint config] [patch] re-add jsx-a11y/accessible-emoji, but disabled
See #2322
2020-11-06 14:19:17 -08:00
Jordan Harband
eee79a5455 [eslint config] [deps] update eslint-plugin-jsx-a11y, eslint-plugin-react 2020-11-06 14:14:17 -08:00
Jordan Harband
b7015dd0b3 [eslint config] [deps] update eslint-config-airbnb-base 2020-11-06 14:12:51 -08:00
Jordan Harband
36f23d7886 [eslint config] [base] v14.2.1 2020-11-06 10:10:00 -08:00
Jordan Harband
e149b05366 [eslint config] [*] [deps] update confusing-browser-globals, object.assign 2020-11-06 10:03:46 -08:00
Jordan Harband
f0492d59bd [eslint config] [*] [dev deps] update @babel/runtime, eslint-find-rules, eslint-plugin-import 2020-11-06 10:01:35 -08:00
Jordan Harband
25b64d7f46 [dev deps] update markdownlint, markdownlint-cli 2020-11-06 09:59:46 -08:00
Kyℓe Hensel
8996aa7c53 [eslint config] [patch] remove deprecated jsx-a11y/accessible-emoji rule 2020-10-27 08:54:41 +13:00
Alex Mercier
05c3bb0018 [eslint config] [patch] Fix ignoreNonDOM typo in jsx-a11y/aria-role rule
This should be `ignoreNonDOM` not `ignoreNonDom` according to [documentation](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md).
2020-10-23 13:30:37 +01:00
alvyn le
d3c7b84d9e [eslint config] [patch] Fixed handle and on ordering in sort-comp rule
- fixes #2116
2020-09-23 01:30:35 -04:00
Samuel Scheiderich
b30b0e4d91 [eslint-config] [base] no-restricted-globals: add better messages 2020-10-24 16:30:10 -04:00
Michael Flores
2c5c88d048 [guide] Update reason for preferring object destructuring
Fixes #2293

The reason for preferring object destructuring is quite narrow in scope. While this guide isn't intended to provide every possible reason for every preference, it perhaps should aim to provide a succinct and compelling reason. The current reasoning could be improved to meet this standard, so I'm proposing adding some additional information to clarify the benefits of what is an often controversial rule (controversial only because its introduction can require many changes in a mature codebase and has no auto fix available).
2020-10-21 23:10:31 -05:00
Daniel Paz
ee2f22a10c [guide] Better link reference to Drupal's linter
This link was taken from their Code standard page: https://www.drupal.org/docs/develop/standards/javascript/eslint-settings

The previous link wasn't very informative and required a download process in order to check their standards.
2020-10-16 14:02:43 +03:00
Daniel Paz
aa43bb2398 [guide] add explanation about why to use radix when using parseInt
I added an explanation at [22.3](https://github.com/airbnb/javascript/blob/master/README.md#coercion--numbers) why to use radix once parseInt, this explanation has been taken from [Mozilla's docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#Octal_interpretations_with_no_radix).

I think it's not clear without an explanation since people can think that it's obvious that string will be parsed to 10 base number, but it's not always the case.
2020-10-14 18:48:40 +03:00
Pirasis
82170f9127 [guide] add eslint rule reference for prefer-object-spread 2020-10-11 21:28:52 +07:00
Pirasis
5ebfe3e5b8 [guide] add eslint rule reference for default-param-last 2020-10-06 21:36:29 +07:00
Android Dev Notes
337f60706f [guide] Fix grammatical errors 2020-09-06 02:02:14 +05:30
Jordan Harband
6006d6d2df [guide] fix dead es-discourse link
Fixes #2274.
2020-08-27 14:29:09 -07:00
Akshath Sivaprasad
a24dc34a4a [guide] [react] Add examples for formatting multiline conditional components 2020-08-05 21:38:20 -07:00
Jordan Harband
1dc71d3839 [guide] [react] add missing PascalCase guidance for prop names 2020-08-03 09:36:24 -07:00
Jordan Harband
973384be1b [eslint config] [*] [dev deps] update @babel/runtime, eslint-find-rules, eslint-plugin-jsx-a11y, eslint-plugin-react 2020-08-05 22:06:20 -07:00
Jordan Harband
3dcc591123 [eslint config] [base] add id-denylist rule 2020-08-05 22:04:10 -07:00
Jordan Harband
c5bee75b1b [eslint config] [*] [deps] update eslint-plugin-import, use valid import/no-cycle maxDepth option 2020-06-22 22:55:52 -07:00
Jordan Harband
5124de23da [eslint config] [base] add new rules from v7.3 2020-06-27 13:22:33 -07:00
Jordan Harband
54955410ee [eslint config] v18.2.0 2020-06-18 13:11:38 -07:00
Jordan Harband
197b50c076 [eslint config] [deps] update eslint-config-airbnb-base, eslint-plugin-jsx-a11y 2020-06-18 11:57:41 -07:00
Jordan Harband
f550ded6da [eslint config] [tests] fix for eslint 7 2020-06-18 12:03:46 -07:00
Jordan Harband
562e3519b8 [Dev Deps] update markdownlint, markdownlint-cli 2020-06-18 11:53:53 -07:00
Jordan Harband
78457af2c5 [eslint config] [base] v14.2.0 2020-06-10 23:25:49 -07:00
Jordan Harband
5b462a04cd [eslint config] [*] [new] add eslint v7 2020-06-10 15:43:13 -07:00
Kristóf Poduszló
22adc06f56 [eslint config] [minor] Allow using eslint-plugin-react-hooks v3 and v4
Co-authored-by: Kristóf Poduszló <kripod@protonmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2020-04-10 00:47:18 +02:00
Jordan Harband
fe2e451ba7 [Tests] add node v14; remove v9, v11 2020-06-10 14:58:23 -07:00
Jordan Harband
b587006077 [eslint config] [*] [deps] update eslint-plugin-import 2020-06-10 14:49:21 -07:00
Vlad Shcherbin
8aee3e1600 [eslint config] [base] [patch] Include 'context' exception for no-param-reassign 2020-05-20 13:21:10 +03:00
Vlad Shcherbin
cad3db3169 [eslint config] [base] [minor] Disallow multiple empty lines 2020-06-07 00:01:51 +03:00
Jordan Harband
7aa0fa14d6 [eslint config] [*] [deps] update eslint-plugin-import, eslint-plugin-react, babel-preset-airbnb, eslint-find-rules, in-publish, tape 2020-06-07 20:50:43 -07:00
Jordan Harband
d34f807459 [Deps] update object.entries 2020-06-07 20:05:48 -07:00
Severiano Badajoz
c48a060aff [eslint config] [patch] set explicitSpread to ignore for react/jsx-props-no-spreading 2020-06-05 15:09:12 -07:00
Paul Matthew Barrameda
06b3ab11d9 [eslint config] [minor] Fix typo in no-multiple-empty-lines rule
## Why is the change being made?

This change is made because the Airbnb documentation states to "avoid a
newline at the beginning of files", yet the code does not follow this.

 ## What has changed to address the problem?

This change fixes the `no-multiple-empty-lines` rule by setting max
beginning of file (`maxBOF`) to from 1 to 0.

 ## How was this change tested?

This change was tested with `npm test`.

 ## Related docs

https://github.com/airbnb/javascript#whitespace--no-multiple-empty-lines
2020-02-19 22:56:52 -08:00
小蚊酱
c0ee2c4924 [guide] unquote properties in whitespace key spacing section 2020-03-31 17:41:38 +08:00
Jiahao
e4f3dd4eff [react] Update Chinese (Simplified) Translation
The translation for Chinese (Simplified) is outdated. Changed to an up-to-date translation that synced with current English version, enhanced expressions for better readability, and also added notes of technical terms for Chinese readers.
2020-03-10 23:24:39 -04:00
Nick Reiley
0375265cbd [eslint config] [base] [patch] Allow triple-slash (///) comments 2020-03-16 23:27:49 +05:00
Nick Reiley
d3628e2600 [eslint config] [base] [patch] Disable prefer-object-spread for airbnb-base/legacy 2020-03-16 23:39:16 +05:00
Jordan Harband
f075a0db50 [eslint config] [patch] relax eslint-plugin-react-hooks down to v2.3, due to a controversial change in v2.5
Fixes #2195.
2020-03-14 15:39:55 -07:00
David J. Bradshaw
d529ccaea3 [eslint config] readme: fix typo 2020-03-14 07:36:30 +00:00
Jordan Harband
a3355f90c4 [eslint config] v18.1.0 2020-03-12 22:58:43 -07:00
Jordan Harband
e7062c32bb [eslint config] [deps] update eslint-config-airbnb-base 2020-03-12 22:47:00 -07:00
Jordan Harband
c75b66daa6 [eslint config] [base] v14.1.0 2020-03-12 16:45:56 -07:00
Jordan Harband
e279b6d3a8 [eslint config] [*] [deps] update eslint, eslint-plugin-react, eslint-plugin-react-hooks 2020-03-12 15:58:42 -07:00
Jordan Harband
6924bd3604 [Dev Deps] update @babel/runtime 2020-03-12 15:58:18 -07:00
Jordan Harband
165af9b6c8 [Tests] actually run the linter on subpackages 2020-03-12 15:41:30 -07:00
Dmitry Semigradsky
e6e6414c97 [guide] Add link to eslint rule for https://github.com/airbnb/javascript#modules--multiline-imports-over-newlines 2020-03-09 12:55:31 +03:00
lagagain
717ba5187a [guide]: add "bigint" type to the primitives type section.
```js
var bn = 123n
```
(with "n" as suffix)
2020-02-28 14:53:58 +08:00
Cain Hall
9890b40677 guide: import/extensions rule documentation 2020-03-02 16:27:57 +11:00
Julian Grinblat
3493b060ec [eslint config] [minor] Support eslint-plugin-react-hooks@2 2019-09-16 19:37:29 +09:00
Jordan Harband
019e0f7e07 [eslint config] add config for disabled new rules 2020-02-13 17:42:08 -08:00
Jordan Harband
41ca203e3e [Dev Deps] update markdownlint-cli 2020-02-07 08:05:47 -10:00
Kévin Berthommier
651280e5a2 [eslint config] [base] Fix indentation with JSX Fragments 2020-02-07 16:49:10 +01:00
Jordan Harband
f86f19cefc [eslint config] [*] [deps] update eslint-plugin-import, eslint-plugin-react 2020-02-07 08:32:08 -10:00
Jordan Harband
4df908033f [eslint config] [*] [dev deps] update @babel/runtime, babel-preset-airbnb, safe-publish-latest, tape 2020-02-07 08:29:46 -10:00
Jordan Harband
377fbcac88 [eslint config] [*] [deps] update object.entries 2020-02-07 08:25:49 -10:00
Geo Artemenko
6d05dd898a [eslint config] [*] [readme] normalize multiline word according to merriam-webster 2019-11-22 22:04:23 -05:00
Jordan Harband
b5954c32b3 [eslint config] [base] [deps] [minor] add new disabled rules, update eslint 2019-12-10 16:47:51 -08:00
Jordan Harband
370793b3dd [eslint-config] [*] [fix] whitespace: only set erroring rules to "warn"
Fixes #2105
2019-12-10 16:32:17 -08:00
Jonas Scheffner
2e3adc98c7 [eslint config] [base] [patch] import/no-extraneous-dependencies: Support karma config files 2019-10-28 13:42:10 +01:00
Vse Mozhet Byt
5927c7f706 [guide] fix possible typo 2019-11-08 16:05:06 +02:00
Igor Gassmann
56b75dc359 [guide] Document class-methods-use-this
This PR documents the currently enforced `class-methods-use-this` ESlint rule as discussed in #2129
2019-11-03 21:00:57 +01:00
trg
64b965efe0 [guide] Fix Temporal dead zone link anchor 2019-10-01 01:27:12 +03:00
Alexander Wesolowski
3fb312f181 [eslint config] [patch] Add static-variables to sort-comp rule 2019-10-04 15:57:05 -07:00
Pirasis
8f78e1f44b [tests] re-enable eslint rule prefer-destructuring internally 2019-10-05 08:01:44 +07:00
Pirasis
5a32c33bf2 [eslint config] [base] [minor] enable import/no-useless-path-segments for commonjs
Fixes #2077.
2019-10-05 08:49:01 +07:00
Pirasis
df2c99c814 [tests] fix eslint errors from c66cfc3 2019-10-05 08:21:45 +07:00
Filipp Riabchun
ab72ab9e90 [eslint config] [patch] Remove duplicate componentDidCatch
See https://github.com/airbnb/javascript/pull/2043#discussion_r331208075

I left the one before `cWU`, as in [defaults](https://github.com/airbnb/javascript/pull/2043#discussion_r331208075)
2019-10-03 21:31:32 +02:00
Jordan Harband
dee4f172e7 [eslint config] [base] add new rules in eslint 6.x, disabled 2019-10-03 19:18:32 -04:00
Jordan Harband
c66cfc3f89 [eslint config] [deps] update eslint-plugin-react 2019-10-03 19:20:10 -04:00
Jordan Harband
8c94d53bf8 [eslint config] [*] [dev deps] update @babel/runtime, babel-preset-airbnb, safe-publish-latest 2019-10-03 19:10:47 -04:00
Jordan Harband
79047a9470 [eslint config] [base] [deps] update confusing-browser-globals 2019-10-03 19:10:12 -04:00
Tom Prats
7932a52e4b Added Tomify and Traitify to the organizations 2019-09-04 14:11:39 -04:00
Daniel Gray
1ca21aba79 [eslint config] clarify hooks section in readme
It took me too long to realize that `"extends": "airbnb/hooks"` won't cut it, and that you need to include both `"extends": ["airbnb", "airbnb/hooks"]`. I think the docs should be explicit about this.
2019-08-17 19:14:24 -05:00
Jordan Harband
295d1e61cb [guide] clean up confusing example from bad rebase
... from
820745d610 (diff-04c6e90faac2675aa89e2176d2eec7d8R963-R965)
/ #1863.

Fixes #2071.
2019-08-14 08:46:21 -07:00
Jordan Harband
a204cdf38a [eslint config] v18.0.1 2019-08-13 12:30:37 -07:00
Jordan Harband
530278467f [eslint config] [patch] react/state-in-constructor: fix incorrect configuration 2019-08-13 12:29:28 -07:00
Jordan Harband
bdba997ac7 [eslint config] v18.0.0 2019-08-10 08:41:05 -07:00
Jordan Harband
1e0a696730 [eslint config] [breaking] disable label-has-for; enable control-has-associated-label 2019-08-09 23:54:08 -07:00
Jordan Harband
73f71d9ba4 [eslint config] [breaking] enable react/jsx-props-no-spreading 2019-08-09 23:53:03 -07:00
Jordan Harband
089022aeff [eslint config] [minor] enable react/static-property-placement 2019-08-09 23:52:44 -07:00
Jordan Harband
7f5a65832d [eslint config] [minor] enable react/state-in-constructor 2019-08-09 23:52:29 -07:00
Jordan Harband
25075b5f72 [eslint config] [minor] enable react/jsx-curly-newline 2019-08-09 23:50:40 -07:00
Jordan Harband
a23f93eb00 [eslint config] [breaking] enable react/jsx-fragments 2019-08-09 23:48:45 -07:00
Jordan Harband
b447768ad3 [eslint config] [deps] update eslint-config-airbnb-base, eslint-plugin-react 2019-08-09 23:48:11 -07:00
Jordan Harband
b05573cae4 [eslint config] [base] v14.0.0 2019-08-09 23:41:02 -07:00
Jordan Harband
e6f591f660 [Dev Deps] update babel-related deps to latest 2019-08-09 23:22:48 -07:00
Jordan Harband
282ef9ea90 [eslint config] [base] [breaking] no-self-assign: enable props option 2019-08-09 22:46:22 -07:00
Jordan Harband
d490ee1806 [eslint config] [base] [breaking] enable no-useless-catch 2019-08-09 22:45:49 -07:00
Jordan Harband
08f8093ed1 [eslint config] [base] [breaking] enable max-classes-per-file 2019-08-09 22:45:27 -07:00
Jordan Harband
d03a712bba [eslint config] [base] [breaking] enable no-misleading-character-class 2019-08-09 22:44:01 -07:00
Jordan Harband
f0c767fd39 [eslint config] [base] [breaking] enable no-async-promise-executor 2019-08-09 22:43:20 -07:00
Jordan Harband
88e71e6e52 [eslint config] [base] [breaking] enable prefer-object-spread 2019-08-09 22:42:20 -07:00
Jordan Harband
11ede40d55 [eslint config] [base] [breaking] func-name-matching: enable considerPropertyDescriptor option 2019-08-09 22:41:33 -07:00
Jordan Harband
e257deebd4 [eslint config] [base] [patch] camelcase: enable ignoreDestructuring 2019-08-09 22:40:53 -07:00
Jordan Harband
6b5922ca21 [eslint config] [breaking] set react version to "detect"
Fixes #1983.
2019-08-09 22:39:06 -07:00
Behnam Mohammadi
a490005ddf [react] event handlers should not return values 2019-07-06 23:45:11 +04:30
Jeff VanDyke
bb011c2f2f [eslint config] [base] [patch] Add markers to spaced-comment block for Flow types
See <https://flow.org/en/docs/types/comments/>
2018-11-29 09:13:54 -05:00
Vladimir Kutepov
8148bfce3c [eslint config] [base] [patch] Do not prefer destructuring for object assignment expression
```js
let param = 'default value';

if (object)
  param = object.param; // <= prefer-destructuring
}

// ...
```
I think that `param = object.param;` is better than `({ param } = object);` because it is easier to read and tedious to write brackets by hand.

MDN: [Destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)
2017-10-10 18:21:50 +03:00
amanjain
19e9ce31fe [eslint config] [base] [breaking] padded-blocks: enable allowSingleLineBlocks option 2017-01-12 12:15:39 +05:30
Felipe Pinheiro
61c7ae6189 [eslint config] Add missing/unsafe lifecycle methods to react/sort-comp rule 2019-06-17 12:58:54 -03:00
Rahil Vora
8c686eac4b [eslint config] add componentDidCatch to lifecycle for react/sort-comp 2019-07-22 11:27:02 -05:00
JBallin
a344d6c8e7 [guide] [eslint config] [base] [breaking] no-multiple-empty-lines: Restrict empty lines at beginning of file 2019-06-10 13:49:58 -07:00
Waseem Dahman
2160a77baa [eslint config] [breaking] [react] add react-hooks plugin 2019-03-12 23:36:07 -04:00
Ed Morley
ad0c44c6af [eslint config] Remove rules/strict from 'extends'
Since the file is now imported in base instead.

Fixes #1582.
2018-11-20 12:06:34 +00:00
Ed Morley
42c647f31b [eslint config] [base] [breaking] Set 'strict' to 'never'
Previously `rules/strict.js` was only used by `eslint-config-airbnb`
and not base. This change reduces the duplication, and means the rule
is now set to 'never' as opposed to the ESLint default of 'safe'.

For users that left the `sourceType` at this preset's default of
`module` this change will be a no-op, since in module-mode the
`strict` rule always behaves as though 'never' had been set.

See:
https://eslint.org/docs/rules/strict#options
2018-11-20 12:04:17 +00:00
Ed Morley
b96341fb86 [eslint config] [base] [breaking] legacy: Enable 'strict'
This enables the `strict` rule in 'safe' mode:
https://eslint.org/docs/rules/strict#safe
2018-11-20 11:55:50 +00:00
Sharmila
f6acb789a0 [guide] [eslint config] [base] [breaking] Simplifies no-mixed-operators
- adds warning on mixing `/` and `*` arithmetic operators
- removes warnings on mixing `**` and arithmetic operators
- removes warning on mixing `in` and `instanceof`
- removes warning on mixing `~` with other bitwise operators
- removes mixing of assignment operators with comparison operators
2018-07-10 15:19:05 -07:00
Sharmila
820745d610 [guide] [eslint config] [base] [breaking] Require parens for arrow function args 2018-07-09 18:14:32 -07:00
Jordan Harband
8eacf24310 [eslint config] [*] [breaking] add eslint v6, drop eslint v4
See #2036
2019-08-09 14:18:55 -07:00
Jordan Harband
3b18fea1ed [Tests] only run tests in non-lint per-package travis job 2019-08-09 14:20:40 -07:00
Jordan Harband
945c62f229 [Tests] on node v12 2019-08-09 14:11:27 -07:00
Jordan Harband
820ccf7652 [eslint config] [*] [tests] use eclint instead of editorconfig-tools 2019-08-09 14:06:58 -07:00
Jordan Harband
792bb567e5 [eslint config] [*] update eslint-find-rules, eslint-plugin-import 2019-08-09 14:04:36 -07:00
Yohan Siguret
6c0a884179 [guide] fix dead jsperf links 2019-08-03 01:04:22 +02:00
Mathieu Dutto
030e23b13e [guide] Fix npm package has usage example 2019-07-24 15:36:48 +02:00
Perttu Ristimella
036612ec3d [inthewile] Add Happeo to users list 2019-07-04 14:59:47 +03:00
Jordan Harband
6a50516df7 [eslint config] [meta] add disabled config for new react and a11y rules 2019-07-01 17:07:38 -07:00
Jordan Harband
21493ad7e9 [eslint config] [base] [deps] update confusing-browser-globals, eslint-plugin-import, tape, babel-preset-airbnb 2019-07-01 16:26:52 -07:00
Jordan Harband
873f302b00 [eslint config] v17.1.1 2019-07-01 16:17:49 -07:00
Jordan Harband
7ea44cfc79 [eslint config] [deps] update eslint-config-airbnb-base, eslint-plugin-import, eslint-plugin-react, eslint-plugin-jsx-a11y, babel-preset-airbnb, tape 2019-07-01 16:12:08 -07:00
Jordan Harband
9fbe07f282 [eslint-config] [base] v13.2.0 2019-07-01 15:05:02 -07:00
Glenn Goossens
a9a83d9150 [guide] add link to new version of Google Style Guide
Add link to a newer version of this guide that includes ECMAScript 6th Edition features
2019-06-27 11:37:32 +02:00
Christian Oliff
76ff7c7f79 [editorial] [docs] correct JavaScript capitalization 2019-06-24 22:45:35 +09:00
Kevin Yue
4539dbcf17 [guide] remove redundant spaces 2019-05-24 16:29:24 +08:00
Kimball Bighorse
19701d4a0c [inthewild] Add Coeur d'Alene Tribe 2019-05-09 09:40:43 -07:00
Joseph Nields
1310ade9d0 [eslint config] [base] [patch] Ignore property modifications of staticContext params
React Router passes a `staticContext` property to children to allow
signalling status codes and redirected URLs, by allowing children to
assign property values to it during render
2019-04-27 14:00:50 -07:00
Jordan Harband
5cd011dfa1 [eslint config] [base] [deps] update eslint-plugin-import 2019-04-27 23:51:44 -07:00
Jordan Harband
117d4fce49 [Tests] fix issue with eslint dev deps 2019-04-27 23:27:07 -07:00
Kévin Berthommier
447466681e [guide] remove extra blank line 2019-04-10 10:22:57 +02:00
Anton Honcharuk
60b96d3222 [guide] Add a 19.9 bullet in a Whitespace section
- with explanations about preventing two blank lines from  appearing consecutively in JavaScript code
2019-02-27 20:25:32 +02:00
Jordan Harband
b85baeafed [eslint config] [base] [meta] add disabled prefer-named-capture-group rule 2019-03-03 23:23:14 -08:00
Anton Honcharuk
be07f7a020 [guide] [react] add more context about arrow functions, as props and in class fields 2019-02-24 13:28:34 +02:00
Matthias Pries
495a62aaa9 [guide] fix example 4.7 for arrays method callbacks 2019-02-13 13:52:39 +01:00
Jordan Harband
da0cf08831 [Tests] on node v11 2019-02-17 14:21:15 -08:00
Jordan Harband
a71c2d1ad3 [eslint config] add disabled jsx-fragments rule 2019-02-17 14:20:53 -08:00
Jordan Harband
834d717c7b [eslint config] [*] [deps] update eslint-plugin-import, eslint-plugin-jsx-a11y, tape 2019-02-17 14:16:48 -08:00
Jamie
8694a87378 [eslint config] [react] [patch] Turn off react/no-multi-comp
Splitting up a component into multiple components can be useful for many reasons, including making important performance optimizations.

This lint rule discourages splitting up components because it forces you to: create a new file, copy over all the relevant imports, move over any local functions/values (or move them into yet another shared module), export the component (which makes your split off component now a public export), and re-import it into the new module.

Having multiple components per file shouldn't be much different from having multiple functions per file. And you shouldn't be forced to make a component a public export if it's really just an internal implementation detail of another component.

There's an argument to be made about _exporting_ multiple components, but mostly just in the context of React.lazy because it can only import default exports and you don't want something else in that file being statically imported (because that will prevent it from being code-split).
2019-02-14 11:57:20 -08:00
Pier-Luc Brault
4f15da6146 [eslint config] [*] [readme] Improve eslint config setup instructions for yarn 2019-02-07 11:48:32 -05:00
Zeeshan Ahmad
6ef45d4bab [guide] make "good" example match "bad" example more closely 2019-02-06 14:09:18 +04:00
tclindner
96f95fa35e [eslint config] [base] [patch] no-extraneous-dependencies: Add jest.setup.js to devDeps 2019-01-29 21:58:23 -06:00
Sharmila Jesupaul
ebe96824e2 Merge branch 'master' into translation-proposal 2019-02-05 11:51:09 -08:00
Jordan Harband
d78af39118 Merge pull request #1996 from remcohaszing/redux-devtools-extension-compose
[eslint config] [base] [patch] Allow use of `__REDUX_DEVTOOLS_EXTENSION_COMPOSE__`
2019-01-27 21:21:48 -08:00
Jordan Harband
d8256fc886 [eslint config] [*] [deps] update object.entries, eslint-plugin-import, eslint-plugin-jsx-a11y, eslint-plugin-react 2019-01-27 13:41:14 -08:00
Jordan Harband
25f11fb31e [eslint config] [patch] extend no-underscore-dangle to allow for redux dev tools in the main config instead 2019-01-26 10:12:49 -08:00
Telmen Munkhdalai
1439ebe78d [editorial] [react] fix typo 2019-01-26 16:55:34 +08:00
Remco Haszing
b6c56cb070 [eslint config] [base] [patch] Allow use of __REDUX_DEVTOOLS_EXTENSION_COMPOSE__
This style guide disallows the use of underscores in properties. However, the
Redux browser extension requires the use of a variable named
`__REDUX_DEVTOOLS_EXTENSION_COMPOSE__`. Since Redux is so popular with React,
it makes sense to allow this.
2019-01-21 13:39:53 +01:00
Hoang
955f4e93b8 Vietnamese translation 2019-01-13 18:55:49 +07:00
Rahil Vora
95286eb496 [guide] [react] add note about forbid-prop-types rule 2019-01-07 10:24:16 -06:00
Jordan Harband
070e6200bb [Dev Deps] update markdownlint-cli 2018-12-28 14:32:02 -08:00
Jordan Harband
387755e8fe [meta] add disabled no-useless-catch config 2018-12-28 14:31:03 -08:00
Jordan Harband
218c4fefbb [eslint config] [base] [fix] disable no-var in legacy entry point
Fixes #1935.
2018-12-28 13:36:01 -08:00
Emily Rohrbough
80920a07c5 Add Terra to README list 2018-12-19 13:06:08 -06:00
Honza Javorek
5d25a2ee61 capitalize means first letter uppercase, the rest lowercase
The examples and the reasoning indicates the author of the rule meant uppercase instead of capitalization. According to Wikipedia, capitalization is "writing a word with its first letter as a capital letter (uppercase letter) and the remaining letters in lower case", while the rule apparently tries to prevent exactly that.
2018-12-18 16:11:26 +01:00
Michael Käfer
064e3bf8d5 :) conflicting with rule 8.2 :D 2018-11-27 20:51:21 +01:00
Kevin Weber
ffe4fe967c [guide] Clarify wording 2018-08-25 22:12:12 -07:00
ernestodebesto
69e34378c6 Examples more consistent with the guidline
comparison operator <= shows better the confusion when using arrow function, than just operator <
2018-09-14 17:20:22 +02:00
NullDev (Chris)
6ece1f58e9 Added NullDev
because why not
2018-11-21 10:51:20 +01:00
NullDev (Chris)
0d6d854b5c [17.2] Added second anchor https://github.com/airbnb/javascript/pull/1960
See requested changes here: https://github.com/airbnb/javascript/pull/1960#pullrequestreview-176797787
2018-11-21 10:48:35 +01:00
Ed Morley
21b65e943c [eslint config] [base] [deps] Switch to confusing-browser-globals
The `eslint-restricted-globals` package author created an equivalent
package `confusing-browser-globals` that now resides within the
create-react-app monorepo. In sidoshi/eslint-restricted-globals#2
@sidoshi suggested that we change eslint-config-airbnb-base to depend
on the CRA package instead, in an effort to consolidate the two.

Currently the two global lists are identical, so this does not change
the generated eslint config:
https://unpkg.com/eslint-restricted-globals@0.2.0/index.js
https://unpkg.com/confusing-browser-globals@1.0.5/index.js
2018-11-20 09:40:02 +00:00
KY3LxD
74deb81d1f [editorial] Improve conciseness of README.md 2018-11-12 23:38:19 -08:00
Bikram Sutar
41a13e83ee [19.16] changed Enforce to avoid
Good practice is to avoid spaces between functions and their invocations. But by mistake (I think so) you used the word Enforce instead of Avoid
2018-10-30 15:05:16 +05:30
Martín Anzorena
03a0734fce Add UrbanSim to organizations list 2018-10-17 01:51:06 +08:00
Pirasis Leelatanon
24da5bb540 [doc] add eslint rule references in react guide
* react/jsx-filename-extension
* react/no-array-index-key
2018-10-04 20:29:10 +07:00
Pirasis Leelatanon
924dfb2682 [doc] add eslint rule reference for no-prototype-builtins 2018-10-03 23:56:48 +07:00
Parul Gupta
9af5ee89eb Updated wording of variable--one-const rule 2018-10-02 16:26:25 +05:30
Tokyo
32a7bf44c2 ✏️ fix docs for whitespace config 2018-09-12 15:37:59 +01:00
侯林江
02b4eea345 [guide] update to a better Chinese translation 2017-01-19 18:21:22 +08:00
Siddharth Batra
e7ffd44b4a Update .markdownlint.json
Fixed typos and grammar
2018-09-02 22:59:40 +05:30
JBallin
17e0454672 [eslint config] [base] [minor] Enforce dangling underscores in method names 2018-09-01 15:48:59 -07:00
Robert Alvarez
b8b2a0b0e0 Add Pier1 to the organization list 2018-08-31 15:10:43 -05:00
Kevin Weber
48448a81cc [guide] [react] Explain use of ID over key right on page 2018-08-26 17:41:01 -07:00
Kevin Weber
5443d03de2 [guide] Consistently use curly quotes instead of straight quotes in prose 2018-08-26 17:50:48 -07:00
Kevin Weber
fcfd378dd8 Fix outdated link to Airbnb's Neutrino preset 2018-08-25 22:54:31 -07:00
Jordan Harband
d774b8979e Merge pull request #1898 from kevinweber/react/props--unnecessary-props
List bad example first to be consistent
2018-08-26 22:21:05 -07:00
Kevin Weber
ced1cb3ad8 List bad example first to be consistent 2018-08-26 17:15:08 -07:00
Jordan Harband
685f37be39 [eslint config] v17.1.0 2018-08-13 13:39:50 -07:00
Jordan Harband
9a5267684b [eslint config] [patch] re-enabling jsx-one-expression-per-line allowing single children, ignore DOM components on jsx-no-bind; re-enable restructuring-assignment
Reverts b6a268f780
2018-08-13 13:35:23 -07:00
Jordan Harband
152b914935 [eslint config] [deps] update eslint-config-airbnb-base, eslint-plugin-react 2018-08-13 13:31:33 -07:00
Jordan Harband
45326cce63 [eslint-config-airbnb-base] v13.1.0 2018-08-13 00:54:48 -07:00
Jordan Harband
dfb70d6244 [*] [deps] update eslint-plugin-import, safe-publish-latest 2018-08-13 00:51:32 -07:00
Jordan Harband
32a674de0b [eslint config] [*] [deps] update eslint, babel-preset-airbnb, eslint-plugin-jsx-a11y 2018-08-03 21:18:03 -07:00
Andrew Scheuermann
a12dec90d1 [guide] [react] boolean in jsx alignment 2018-07-11 16:26:22 -07:00
Jordan Harband
b6a268f780 [eslint config] [react] disable two buggy rules, temporarily 2018-07-09 23:16:25 -07:00
Vse Mozhet Byt
96317f8c79 [guide] fix anchor tag in README.md
Currently, this anchor with missing end tag breaks rendering:

5d1f4b9a49/README.md (arrays--from-iterable)
2018-07-05 16:48:26 +03:00
Jordan Harband
a510095acf [eslint config] [*] [new] add eslint v5 support 2018-06-25 15:06:18 -07:00
Jordan Harband
2037fd82b9 [Tests] link eslint from the base config as well 2018-06-25 15:48:07 -07:00
Jordan Harband
7dda84a335 [eslint config] [deps] [minor] update jsx-a11y plugin; enable label-has-associated-control rule
This is semver-minor, because the `label-has-associated-control` rule is
the same as the `label-has-for` rule, theoretically. Both remain
enabled, but `label-has-for` will be disabled in the future if this rule
proves out.
2018-07-04 22:33:27 -07:00
Mauro Zenoni
5d1f4b9a49 [guide] Updated Arrays Section
- corrected paragraph 4.4 (conversion from iterable to array)
- added paragraph 4.5 (conversion from array-like to array)
2018-07-03 11:51:37 +02:00
Ahmed Tarek
fe8de59977 [eslint-config] [*] [docs] ✏️ fix typo in Readme 2018-07-03 21:18:11 +02:00
Noah Benham
77fdae6a74 Add Cerner to In The Wild
[Cerner](https://github.com/cerner/) uses Airbnb for our JS projects.
2018-07-02 09:17:21 -05:00
Jordan Harband
27e5e20b70 [eslint config] [base] [new] update base ecmaVersion to 2018; remove deprecated experimentalObjectRestSpread option 2018-06-25 14:14:01 -07:00
Jordan Harband
d951220399 [eslint config] [*] [dev deps] update eslint-find-rules 2018-06-25 13:40:38 -07:00
liyuhang
4702115038 Fix: Typo 2018-06-25 16:08:50 +08:00
Jordan Harband
363bb07765 [eslint config] [deps] update eslint-plugin-react 2018-06-24 22:57:06 -07:00
薛定谔的猫
6a593069e1 [dev deps] update markdownlint-cli 2018-06-25 02:09:32 +08:00
Jordan Harband
8de558b750 [eslint config] [*] [deps] update eslint-plugin-import 2018-06-24 19:41:27 -07:00
薛定谔的猫
2161ddf8d6 Build: add node 10 2018-06-25 02:08:15 +08:00
Jordan Harband
cae920fc30 [eslint config] v17.0.0 2018-06-21 15:22:10 -07:00
Jordan Harband
d14ed5daa7 [eslint config] [breaking] update eslint-config-airbnb-base 2018-06-21 15:16:52 -07:00
Jordan Harband
afe340773f [eslint config] [base] v13.0.0 2018-06-21 14:46:43 -07:00
Jordan Harband
8be089eb11 [eslint config] fix tests 2018-06-21 14:46:24 -07:00
Jordan Harband
fdb998b38a [eslint config] [base] fix tests 2018-06-21 14:39:07 -07:00
Jordan Harband
951825c6d2 [eslint config] set forbid-foreign-prop-types to "warn" 2018-06-21 14:22:54 -07:00
Gaurav Paliwal
25e711cedd [eslint config] [patch] Add new methods introduced in react@16.3 2018-06-20 17:31:00 +05:30
Moritz Kneilmann
068d6b69bf [eslint config] [base] [patch] Adjust imports for vue-cli
Allows the vue-cli config file `vue.config.js` to import `devDependencies` by altering the rule `import/no-extraneous-dependencies`.
2018-05-15 23:54:09 +02:00
Josh Wells
b3bbd1ccbc [eslint config] [base] [breaking] order of import statements is ignored for unassigned imports 2018-04-11 13:46:34 +01:00
minimooooz
2668495fee add ES2015-2018 in npm package keywords 2017-10-12 11:17:22 +07:00
Jordan Harband
d270031fc0 [eslint config] [*] [dev deps] update babel-preset-airbnb, tape 2018-06-21 13:28:22 -07:00
Vse Mozhet Byt
103f5e2a59 doc: add missing anchor in README.md 2018-06-08 19:49:37 +03:00
Daniel McNally
74fb34f08d Add no-unused-vars to README
This documents the enforced but currently undocumented `no-unused-vars` rule with a brief description, examples, and noting the `"ignoreRestSiblings": true` option.
2018-06-08 02:02:11 -04:00
Jordan Harband
5e260928b6 [eslint config] [react] update eslint-plugin-react 2018-06-03 22:19:41 -07:00
Alejandro García Salas
8a24480119 Fix broken aria roles link in React style guide README 2018-06-03 10:48:10 -07:00
Andrew Macpherson
dfc9da71d9 Add Drupal to In The Wild section. 2018-06-01 01:08:04 +01:00
Alexandre Syenchuk
ae82d76783 Update README.md 2018-05-30 09:06:14 +02:00
Jordan Harband
04ab225858 [eslint config] [*] [deps] update eslint-plugin-import, eslint-find-rules, eslint-plugin-react 2018-05-27 08:47:29 -07:00
Brett
c068d7cbf1 Fix link for Temporal Dead Zone 2018-05-26 13:38:45 -07:00
ParkSB
2ba36de952 [guide] Add backticks 2018-05-05 03:04:38 +09:00
Jimmy Jia
2bd77bc1e0 [eslint config] [base] [patch] label-has-for: Remove redundant component
Also make the rule configuration more explicit.
2018-05-05 22:34:19 -04:00
Vse Mozhet Byt
71e54f2af8 doc: fix some nits in README.md
* Add missing anchors for section references.
* Correct a rule description.
2018-05-04 11:11:55 +03:00
Daniel McNally
edf942eeb6 [guide] Add descriptions of enforced rules
This commit adds brief descriptions and examples of rules enforced by the guide that were not previously mentioned in the README.
2018-05-02 01:01:19 -04:00
Thomas Grainger
2d9779907f [eslint config] [base] [minor] only allow one newline at the end 2018-04-30 09:30:38 +01:00
Joe Lencioni
8c83d03a20 [eslint config] [base] [patch] Allow devDependencies for foo_spec.js naming style
Some projects name test files like `foo_spec.js` instead of `foo.spec.js`.
2018-02-15 11:58:17 -08:00
Feross Aboukhadijeh
22f01558a0 Add StandardJS to "Other Style Guides" list
StandardJS is one of the top style guides, though like the Google and jQuery styles, it's less popular than the airbnb style. 😀
2018-04-25 20:28:41 -07:00
Nguyễn Tiến Minh
2653730fee [react] add vietnamese 2018-04-21 13:51:56 +07:00
Jordan Harband
5705b8ae6b Revert "Replace flag images with emoji"
This reverts commit 87f97e042d.

Closes #1789.
2018-04-22 14:48:50 -07:00
Jordan Harband
fd0834764c [eslint config] [base] fix tests 2018-04-20 15:19:14 -07:00
Jordan Harband
b56875bee2 [eslint config] [base] [patch] function-paren-newline: change to "consistent" 2018-04-20 14:00:50 -07:00
Joe Lencioni
89bb98e135 Merge pull request #1787 from airbnb/lencioni-patch-2
Replace flag images with emoji
2018-04-19 04:15:39 +08:00
Joe Lencioni
87f97e042d Replace flag images with emoji
We can use emoji for most of these flags, which should make
them look better on higher resolution displays and improve the
loading performance of the style guide a little.

The only flag we have here that does not have a good emoji yet
is the flag of Catalonia, which I left as-is for now.

https://emojipedia.org/flag-for-catalonia-esct/
2018-04-18 11:28:06 -07:00
Jordan Harband
308fb24815 [eslint config] [*] [deps] update eslint-plugin-import 2018-04-13 13:43:43 -07:00
Jordan Harband
6088a8f5b5 [guide] remove references to jscs 2018-04-12 15:46:55 -07:00
Eray Çetinay
8956338ee9 [guide] Turkish Translation Link Added 2018-04-08 22:51:19 +03:00
Hernaldo Jesus Henriquez
06998522e1 [guide] fix "bad" comment to be actually bad 2018-04-06 14:53:46 -03:00
C. T. Lin
8720f5f90b [eslint config] [base] [patch] avoid __mocks__ no-extraneous-dependencies check 2018-03-28 13:05:12 +08:00
Pramod Garg
bd97fca21b [guide] Minor addition of spaces 2018-04-04 22:45:44 +05:30
Sharmila
c71e8c9231 [eslint config] [base] [breaking] enable import/no-cycle: warn on cyclical dependencies 2018-04-04 16:15:27 -07:00
Sharmila
31d95fded4 [eslint config] [*] [deps] update eslint, eslint-plugin-import, eslint-find-rules 2018-04-04 16:23:02 -07:00
Simon Owen
06e28997b2 Minor spacing update 2018-03-28 15:39:14 +01:00
Jordan Harband
33819d6787 [guide] Added naming conventions for UPPERCASE use cases
Merge pull request #255 from estelle/master
2018-03-23 22:29:20 +00:00
Naomi Jacobs
8ed1d855bb [eslint config] [base] [patch] Include 'accumulator' exception for no-param-reassign 2018-03-20 11:40:04 -07:00
Joe Lencioni
49dab881da Change import/no-self-import from "off" to "error"
We recently had an incident where this rule would have prevented
infinite loops in Hypernova and in the browser.
2018-03-23 08:42:42 -07:00
Shane Mileham
a9f5d519fe Added naming--uppercase section from comment 2018-03-12 11:20:34 -07:00
Remco Haszing
8247e338a2 [eslint config] [base] [patch] Set import/extensions to ignorePackages
This allows to import non-JavaScript files through the main export of a dependency's package.json.

The following would trigger an error before, but is fine with the new configuration:

```js
import 'roboto-fontface';
```
2017-12-04 10:11:35 +01:00
Remco Haszing
a100a3957f [eslint config] [base] [breaking] Update object-curly-newline to match eslint 4.18.0
In eslint v4.18.0 separate settings are introduced for imports and exports for the `object-curly-newline` rule.

Without this change, there is different behavior when updating eslint to this version.
2018-03-01 14:33:02 +01:00
Michael Altamirano
55adae99c9 [guide] Reflect adoption of jest 2018-03-10 17:30:38 -08:00
Rauno
a9fc9d8a0f [docs] [js] add function-paren-newline eslint reference link 2018-03-05 22:24:19 +02:00
Pirasis
396166b1d3 [eslint config] [*] [fix] ensure whitespace entry point is compatible with node 4 2018-03-01 12:15:56 +07:00
Jordan Harband
40dbeace17 [Tests] ensure all entry points parse 2018-02-28 23:00:19 -08:00
Jordan Harband
8e6363c677 [eslint config] [*] [new] add whitespace entry point
Adds eslint config extends with only whitespace rules enabled

Merge pull request #1749 from airbnb/whitespace-rules
2018-02-28 19:01:56 -08:00
Sharmila
6373dab990 Adds config entry point with only whitespace rules enabled
Adds a change to eslint-config-airbnb and eslint-config-airbnb-base to pull a list of rules from the project root and return a config with all rules turned off except the whitespace rules explicitly listed in the array. Also adds entry point data to readme.
2018-02-27 15:21:29 -08:00
Thomas Grainger
c82500d7fa [eslint config] [base] [breaking] enable no-useless-path-segments 2018-02-22 01:07:09 +00:00
Jordan Harband
1fbeabd0c4 [eslint config] [*] [breaking] [deps] update eslint, eslint-plugin-import 2018-02-22 13:51:02 -08:00
Rauno Freiberg
fd68fdbd22 [guide] [react] add comment about what JS standards are followed
Seen a few pull requests for the React style guide that try to introduce features that aren't yet in stage >= 3 (static class fields for i.e), so I've decided to add a comment to the beginning of the guide. Not sure if this is the right place to put it, but here it is.

This disclaimer might help:
1) give the community an idea what standards this guide is based on
2) prevent redundant pull requests
2018-02-20 19:28:52 +02:00
Honza Javorek
ea14bda110 Add licenses to sub packages 2018-02-22 15:48:50 +01:00
Song Xie
a7a7cab504 [guide] Add an anchor for rule 13.7 2018-02-21 14:44:58 -08:00
Jordan Harband
3c3074e502 [eslint config] [*] [deps] update eslint, eslint-find-rules, eslint-plugin-react, tape 2018-02-20 00:10:46 -08:00
Jordan Harband
ff1c12178e [eslint config] [breaking] update eslint-plugin-react to v7.6; update rule configs 2018-01-26 23:31:30 -08:00
Rauno Freiberg
901fd85b7c Use single quotes for consistency 2018-02-19 14:58:24 +02:00
Jordan Harband
cfe10c17d3 fix linting error in guide 2018-02-08 21:45:14 -08:00
Kevin Ji
4c870cbd40 [guide] Fix function signature spacing 2018-02-08 11:29:44 -08:00
Gil Birman
c8b1164105 control-statement--value-selection 2 2018-02-08 13:07:34 -08:00
Ajay Poshak
16190d8cb5 Note added for translation 2018-02-04 18:52:51 +05:30
Teddy Katz
c5411a42d2 Suggest using WeakMaps when hidden properties are needed
This updates the "trailing or leading underscores" guideline to suggest an better way to make properties hidden, as an alternative to just removing the underscore and making the property public.
2018-02-04 17:11:01 -05:00
ParkSB
aefff97bd1 Update Korean translation link 2018-01-30 11:49:24 +09:00
David Clark
9a3e6356cf Added GreenChef organization to README 2018-01-28 00:38:48 -07:00
Ali Oğuzhan Yıldız
17b6491ae2 add Turkish translation 2017-09-04 00:00:04 +03:00
Antonio Erdeljac
1eefaed4fb [guide] [css] Fixed Italic subtitle in css-in-js README.md 2018-01-10 09:08:21 +01:00
Jérémie Astori
fc99aefc4c [guide] Use acc as reduce accumulator instead of memo to make it valid
In [this part of the `no-param-reassign` configuration](53b2d7d245/packages/eslint-config-airbnb-base/rules/best-practices.js (L174-L175)), `acc` is allowed to be mutated (rule [7.12](https://github.com/airbnb/javascript#functions--mutate-params), but `memo` is not.

This causes the [rule 4.6 example](https://github.com/airbnb/javascript#arrays--callback-return) in the README to actually be invalid.
2018-01-26 13:16:39 -05:00
Sharmila
e9fff7adbf [eslint config] [base] [breaking] Prevent line breaks before and after = 2018-01-26 10:57:21 -08:00
Alex Baulch
53b2d7d245 [eslint config] [breaking] bump react pragma to v16; update class-methods-use-this's exceptMethods to include componentDidCatch 2018-01-22 10:42:28 +00:00
zwei
c4dcfd93a7 [guide] fix indentation in section 4.7 2018-01-16 16:20:46 +08:00
Jordan Harband
7dab8371c9 [eslint config] [deps] update eslint 2018-01-20 23:36:32 -08:00
Jordan Harband
7b1ced2bf7 [eslint config] [base] [deps] update eslint 2018-01-20 23:35:21 -08:00
Ben Fortner
262b07b106 fix example to meet standard listingId v listingID
fixed code example to meet the standard. `listingId` changed to `listingID` 
See - Naming Conventions: Acronyms and initialisms should always be all capitalized, or all lowercased.
2018-01-16 09:55:54 -05:00
Aditya Agarwal
a08afd77d5 [eslint-config] [*] [docs] add npx shortcut 2018-01-10 20:04:25 +05:30
Jordan Harband
be647a77fb Merge pull request #1538 from lanceli/patch-1
Change Simplified Chinese translation link
2018-01-09 22:32:15 -08:00
Jordan Harband
69a3554100 [eslint config] [base] [patch] properly ignore indentation on jsx
Fixes #1658.
2018-01-08 00:52:17 -08:00
Jordan Harband
7b18d7c215 [eslint config] [*] [deps] update eslint 2018-01-08 00:35:15 -08:00
Jordan Harband
35f3e76edd Merge pull request #1691 from airbnb/update-mixed-operators-text
[guide] Improves wording of no-mixed-operators recommendation.

Fixes #1678.
2018-01-08 14:57:11 -08:00
Sharmila
fe3a2de6b5 [fixes: #1678] Improves wording of no-mixed-operators recommendation. 2018-01-08 14:37:32 -08:00
Jordan Harband
ea8fd76c5e [eslint config] [base] [breaking] Add .mjs extension support
Merge pull request #1635 from olistic/add-mjs-extension-support
2018-01-02 22:52:01 -08:00
Miguel Piedrafita
cb9482c04e [guide] Update license year 2018-01-01 00:50:59 +01:00
Jordan Harband
f9fcb37af1 [guide] Add link to "has" package
Fixes #1670.
2017-12-25 10:37:36 -08:00
Jordan Harband
0991476c9f [guide] Clarify that vars are hoisted to function scope, not block scope
Fixes #1675.
2017-12-25 10:27:33 -08:00
Jordan Harband
1b6bcd0e0f [guide] more precisely refer to an "object literal" instead of just a "hash"
Fixes #1680.
2017-12-25 10:24:54 -08:00
Ronald Eddy Jr
fc34709d19 Docs: HTTP -> HTTPS
URL was updated to use HTTPS protocol
2017-12-24 13:20:12 -08:00
Pirasis
90235cab7c [eslint config] [base] [patch] array-callback-return: enable allowImplicit option 2017-12-24 10:06:09 +07:00
Jordan Harband
9061044af0 [eslint config] [*] [deps] update eslint, eslint-plugin-jsx-a11y 2017-12-23 20:25:29 -08:00
Thomas Broadley
8a12ffed19 [guide] Fix spelling error in link
(preserve old link for back-compat)
2017-12-15 20:31:09 -05:00
Ilici
255b0f369a Fix third example in Enclosed operators section 2017-12-14 23:14:27 +01:00
Kristóf Poduszló
4817a6b75c [eslint config] [patch] Add 'to' as a specialLink to the 'anchor-is-valid' a11y rule
Support React Router's `<Link to="...">` attribute out of the box.
2017-11-28 19:47:00 +01:00
Jordan Harband
b709023494 [eslint config] [base] [breaking] enable implicit-arrow-linebreak 2017-11-29 23:52:45 -08:00
Jordan Harband
2087a42b51 [eslint config] [base] [deps] update eslint 2017-11-29 23:43:55 -08:00
Matias Olivera
eb50272401 Forbid .mjs extension from being specified 2017-11-05 13:23:21 -03:00
Matias Olivera
1d9d25d278 Add .mjs to the list of supported extensions 2017-11-05 13:21:48 -03:00
Josh Bourgeois
8cf2c70a41 [guide] Add explanation for semicolon enforcement rule
Also update code samples to highlight ways in which ES6
currently mishandles code when relying on Automatic Semicolon
Insertion

Revise hyperlink and example

- Use more up-to-date TC39 reference page on github.io
- wrap returnless function with side-effects in curly braces

also, clean up punctuation on a long comment line

Always use single-quoted strings

Except for when the string needs to be double-quoted because the string contains apostrophes

Update second example to incorporate IIFE

An IIFE is a more realistic example of code that developers may encounter which would raise an exception when relying completely upon ASI
2017-10-04 13:38:13 -07:00
Jordan Harband
44dbd0bdc4 [eslint config] [patch] disable no-did-mount-set-state, since it’s necessary for server-rendering.
Fixes #684.
2017-11-04 01:02:09 -07:00
Maggie Love
5682155e9a Adds section about spreading props 2017-11-01 18:33:54 -04:00
Jordan Harband
1948c302fd [Tests] on node v9; use nvm install-latest-npm so new npm doesn’t break old node; pin included builds to LTS. 2017-11-01 08:01:50 -07:00
Ed Morley
7ff6303513 [guide] Use HTTPS for links to ESLint documentation
The result of a `s_http://eslint\.org_https://eslint\.org_g`.
Avoids the HTTP 302s of the non-HTTPs URLs.
2017-10-30 13:19:22 +00:00
Jordan Harband
2d4343acd1 [guide] remove/update outdated links.
Fixes #1626.
2017-10-27 22:10:32 -07:00
Vse Mozhet Byt
c40d0d1f84 [guide] Fix a link, add an anchor 2017-10-28 03:41:29 +03:00
Jordan Harband
9edcdde8fe Merge pull request #1620 from lasota-piotr/classname-props
[guide] [react] Added anti-pattern example for Props Naming rule, changed className props in examples
2017-10-25 13:33:52 -07:00
Pirasis Leelatanon
dbdf8ea0ef [doc] add eslint rule reference for no-multi-assign 2017-10-26 02:21:23 +07:00
Pirasis Leelatanon
327795bf3c [doc] add eslint rule reference for no-new-wrappers 2017-10-26 02:36:13 +07:00
Piotr Lasota
9d3e7e0a2c Add component with className as anti-pattern example 2017-10-25 20:05:40 +02:00
Piotr Lasota
999fe3b83a Change className to variant in examples 2017-10-25 20:03:56 +02:00
Sharmila
2676cbfb2f [eslint config] [base] [breaking] Enables nonblock-statement-body-position rule and adds link to guide 2017-10-24 17:49:14 -07:00
Jordan Harband
8a477f9893 Merge pull request #1616 from leonidlebedev/patch-1
Remove unnecessary variables
2017-10-24 13:27:03 -07:00
Leonid Lebedev
ecf8e077a7 Remove unnecessary variables 2017-10-24 14:33:47 +03:00
Arnav
bd3ba6edfe Add symbol as a primitive type
- Also add note that symbols cannot by polyfilled and should not be used in environments that don't support them
2017-10-23 15:04:58 -07:00
Vse Mozhet Byt
dbd69346bd [guide] Fix a numeration typo in README.md
- also remove legacy numbered link
2017-10-24 00:07:05 +03:00
Sharmila
8161f32f1f [eslint config] [base] [breaking] no-mixed-operators: only warn on ** and % mixed with arithmetic operators; removes violation against mixing common math operators.
Fixes #1071.
2017-10-20 16:09:16 -07:00
Liu Chong
97a6883621 Fix markdown style breaking
It came from the special characters "M-BM-":

```
diff README.md README.md.new | cat -A
651c651$
<     const foo = function uniqueMoreDescriptiveLexicalFoo() {$
---$
>  M-BM-  M-BM- const short = function longUniqueMoreDescriptiveLexicalFoo() {$
```
2017-10-22 14:10:35 +08:00
刘冲
232b719fc5 To Clarify the func-style description
As "foo" is still meaningless, but with "short", we can see that, we are intend to use a short alias name to make our coding happily.
2017-10-21 22:11:18 +08:00
Jordan Harband
94c47734e8 [eslint config] [*] [deps] update eslint-plugin-import 2017-10-20 15:48:09 -07:00
jabacchetta
3c6d40ccca [docs] Clarify reasoning for named function expressions
For convenience, added brief explanations that are given in the linked discussion (mostly eliminating the need to scroll through the comments).
2017-10-19 19:46:28 -05:00
jabacchetta
39cf84f43b [guide] Add clarification to arrow functions
Clarify and correct explanation — to be consistent with section 7.1 (use named function expressions).
2017-10-19 18:59:41 -05:00
Sharmila
67e34433e4 Adds guide section for no-return-else 2017-10-18 21:30:02 -07:00
Jordan Harband
8cfc97eee9 [Tests] fix linting tests 2017-10-18 21:28:52 -07:00
Jordan Harband
6f2395a3f1 [eslint config] [base] [breaking] import/named: enable 2017-10-18 14:28:58 -07:00
Jordan Harband
b66d6e42f3 [eslint config] [base] [breaking] lines-between-class-members: set to “always” 2017-10-18 14:27:41 -07:00
Sharmila
2b3c86d812 Fixes indentation 2017-10-18 14:50:58 -07:00
Jordan Harband
8507df4f78 Merge pull request #1600 from airbnb/shar--enforce-operator-linebreak-before
Enforce operator at the beginning of line
2017-10-18 14:26:53 -07:00
Sharmila
cd4ec29ed3 [eslint config] [base] Enables eslint rule for operator-linebreak
Requiring operators at the beginning of the line makes code more readable. When operators are on the left hand side they mirror the syntax of method chaining and it is easy to see the build of logic in a statement. This also updates the readme and fixes a style violation as a result of adding this rule in eslint-config-airbnb/test/test-base.js and eslint-config-airbnb-base/test/test-base.js.
2017-10-18 14:15:39 -07:00
Thomas Grainger
01e72b9963 [eslint config] [base] [breaking] no-else-return: disallow else-if 2017-10-18 14:06:04 -07:00
Sharmila
f2a65c6898 Improves 'Why?' message 2017-10-18 13:41:24 -07:00
Sharmila
6fbc47256e Fixes test syles 2017-10-18 13:37:49 -07:00
Sharmila
2ab0e61858 Updates Control Statements section to reflect eslint config change 2017-10-18 13:37:49 -07:00
Sharmila
6e1f11185d [eslint config] [base] Enables eslint rule for operator-linebreak
Requiring operators at the beginning of the line makes code more readable. When operators are on the left hand side they mirror the syntax of method chaining and it is easy to see the build of logic in a statement.
2017-10-18 13:37:49 -07:00
Jordan Harband
cf9e17efee [eslint config] v16.1.0 2017-10-16 12:01:21 -07:00
Jordan Harband
ec4b9b109a [eslint config] [deps] update eslint-config-airbnb-base, eslint to v4.9 2017-10-16 12:00:49 -07:00
Jordan Harband
7f61af685c [eslint config] [base] v12.1.0 2017-10-16 11:50:50 -07:00
Pirasis Leelatanon
9025c52a73 [doc] add eslint rule reference for prefer-destructuring 2017-10-16 21:18:48 +07:00
Jordan Harband
3581bac32f [eslint config] [base] [deps] update eslint to v4.9 2017-10-16 11:42:13 -07:00
Joe Lencioni
f8f13d9bf1 Merge pull request #1591 from 1pete/patch-2
sort peerDependencies in alphabetical order
2017-10-12 20:44:02 -07:00
Pirasis Leelatanon
62d8d66049 [eslint config] sort peerDependencies in alphabetical order 2017-10-13 10:38:23 +07:00
David Künnen
ac2ed5a749 Added our company to "In The Wild" 2017-10-12 13:30:18 +02:00
Jordan Harband
dfbeaaea4b [eslint config] v16.0.0 2017-10-06 10:40:05 -07:00
Jordan Harband
e5b5aeeb6b [eslint config] [breaking] enable/add react rules:
- `react/jsx-curly-brace-presence`
 - `react/no-typos`
 - `react/no-unused-state`
 - `react/no-redundant-should-component-update`
 - `react/default-props-match-prop-types`
2017-10-05 01:01:01 -07:00
Jordan Harband
2c228825a8 [eslint config] [deps] update eslint, eslint-config-airbnb-base, eslint-plugin-react 2017-10-05 00:55:14 -07:00
Jordan Harband
ad3746672e [eslint config] [base] v12.0.2 2017-10-05 00:03:21 -07:00
Jordan Harband
a8155091ff [eslint config] [base] [deps] update eslint 2017-10-05 00:02:31 -07:00
Jordan Harband
4170a50732 Merge pull request #1574 from leonidlebedev/patch-1
[guide] Add Amendments
2017-10-01 12:00:11 -04:00
Leonid Lebedev
faedb67042 Add Amendments 2017-10-01 17:36:45 +03:00
Jordan Harband
cd038fb89b v12.0.1 2017-09-27 16:38:49 -04:00
Jordan Harband
b7ff33e79c [eslint config] [base] [deps] update eslint 2017-09-27 16:37:54 -04:00
Jordan Harband
8e29a161f9 [eslint config] [base] [fix] ensure all JSX elements are ignored by indent
Fixes #1569.
2017-09-27 16:33:51 -04:00
Josh
2380c0ddb8 [guide] Improve severity of warning comment 2017-09-27 12:51:40 -07:00
Vladimir Kovpak
3ad1ad1a6a [guide] Updated example in ternaries. 2017-09-21 02:11:14 +03:00
Nikita Lebedev
e16b03b841 [guide] require array spread operator or Array.from
Fixes #1084.
2017-09-20 14:12:25 -07:00
Carlos Soria
0aab14c364 Add Grupo Abraxas to In The Wild section 2017-09-14 16:09:30 -05:00
Jordan Harband
5b338e1937 [Tests] lint our markdown 2017-09-02 11:33:45 -07:00
Jordan Harband
e86fb14932 Merge pull request #1551 from vitalymak/patch-1
[eslint config] [base] fix typo in changelog
2017-09-07 10:27:56 -07:00
Vitaly Makarevich
138aafd2a0 Update CHANGELOG.md
Typo: prefer-restructuring => prefer-destructuring
2017-09-07 17:26:11 +03:00
Jordan Harband
9dee84796b [Docs] add note about requiring babel-preset-airbnb and airbnb-browser-shims.
Fixes #1544.
2017-09-02 11:28:53 -07:00
Lance Li
d493a04d7f Change Simplified Chinese translation link
Currently the Simplified Chinese translation is for ES5, it's out of date, use another one instead of it.
2017-08-26 14:49:14 +08:00
Jordan Harband
22672c1cdc [eslint config] [new] add propWrapperFunctions default settings for eslint-plugin-react 2017-08-22 19:44:12 -07:00
Jordan Harband
f93ca2f71d [eslint config] [deps] update eslint v4, eslint-plugin-react 2017-08-22 17:16:31 -07:00
Jordan Harband
db719a2033 [eslint config] [deps] update eslint-config-airbnb-base 2017-08-22 17:10:01 -07:00
Joe Lencioni
68cdc59362 [eslint config] [new] Enable react/jsx-closing-tag-location 2017-08-22 15:38:13 -07:00
Jordan Harband
f1cc91c88a [eslint config] [base] v11.3.2 2017-08-22 15:54:17 -07:00
Jordan Harband
5637c8f4c0 [eslint config] [base] [deps] update eslint, tape 2017-08-22 15:43:40 -07:00
Dhruvdutt Jadhav
a79237b020 [guide] [react] add another “good” example 2017-08-17 22:54:31 +05:30
Max Kaplan
09988e34b4 [inthewild] adding kaplan komputing 2017-08-20 09:24:03 -04:00
Anton Vasyunin
855426b3db Update section on naming conventions for acronyms
- Fix array name starting with a capital
- Add alternative good example
2017-08-18 00:05:21 +07:00
Wooram Jun
344c25d83a Fix a wrong link 2017-08-17 15:35:14 +09:00
Mark Larah
1cddb4f2c0 [eslint config] [base] [patch] Add jest.config.js to import/no-extraneous-dependencies devDeps 2017-08-14 19:49:29 -07:00
Jordan Harband
6bd73560ee [eslint config] [deps] update eslint v4, eslint-plugin-react, tape 2017-08-09 17:35:23 -07:00
Jared Deckard
b5e14dc5d0 Explain why default exports are preferred 2017-08-07 15:36:22 -05:00
marhub
dbdbde0b81 Remove polish translation
Remove link to polish translation as it's outdated ( last commit from 2-3 years ago ). 
For example in polish translation you can read that you should use one "var" keyword to declare your vars.
example:
```js
// źle ( bad )
var items = getItems();
var goSportsTeam = true;
var dragonball = 'z';

// dobrze ( good )
var items = getItems(),
    goSportsTeam = true,
    dragonball = 'z';
```
2017-08-07 12:48:54 +02:00
Eric Pan
16faade698 [eslint config] [*] [docs] Specify yarn-specific install instructions
Attempts to clarify and address issue https://github.com/airbnb/javascript/issues/1508#issuecomment-319113807

Recommends yarn users to list peer dependencies and then install each peer dependency with specified version.

Prior yarn instructions led users to install the latest version of each peer dependency which, in some cases, led to errors if the latest version of a peer dependency did not have rules that this package uses.
2017-07-31 11:19:07 -07:00
Chris Atkin
e4f35ac959 Removing "GitHub" from In The Wild reference
This removes the word "GitHub" from an In The Wild reference link, to prevent association with the main GitHub organisation.
2017-07-31 17:12:27 +01:00
Will Clark
a206c52854 [eslint config] [base] [patch] Improve Gruntfile glob pattern
To cover `Gruntfile` and `Gruntfile.js` instead of just `Gruntfile`.
2017-07-25 11:41:34 +02:00
Jordan Harband
abeb313333 Merge pull request #1505 from asherdale/master
Update README, fixed badly-styled eslint links
2017-07-25 23:35:25 -07:00
Asher Dale
9393e6ab10 Update README, finished fixing eslint styling
Update README, finished fixing eslint styling (look at previous commit description for info).
2017-07-25 15:50:10 -04:00
Asher Dale
a371d73414 Update README, fixed badly-styled eslint links
There were links to eslint rules in a style that didn't match the style of the rest of the document. Specifically, most links in the document use the following style: "eslint: ['no-unneeded-ternary']", but there were badly styled links that looks like this: "eslint rule: ['no-unneeded-ternary']." Additionally, the badly styled links were on their own line, whereas all the other links are not placed on their own line.
2017-07-25 15:46:30 -04:00
Asher Dale
3cc6269c86 Updated README, deleted extra 'back to top'
There was an extra 'back to top' link in between sections 4.5 and 4.6 in the 'Arrays' section.
2017-07-20 11:21:29 -04:00
Jordan Harband
106a58ec1a [eslint config] [base] v11.3.1 2017-07-24 12:07:43 -07:00
Jordan Harband
0d938aecf2 [eslint config] [base] [fix] legacy: remove top-level ecmaFeatures 2017-07-24 11:58:15 -07:00
Jordan Harband
2c0126543f [eslint config] v15.1.0 2017-07-24 00:00:58 -07:00
Jordan Harband
16c73d0a7a [eslint config] [deps] allow eslint v3 or v4
Closes #1447.
2017-07-23 22:33:05 -07:00
Jordan Harband
583544356a [eslint config] [deps] update eslint-plugin-import, eslint-config-airbnb-base 2017-07-23 22:26:33 -07:00
Stephen Wyatt Bush
074b2f81b8 [eslint config] [breaking] [deps] Upgrade eslint-plugin-jsx-a11y to v6
- enable more a11y rules
2017-07-05 15:47:54 -07:00
Jordan Harband
7b30681227 [eslint config] [breaking] [deps] require eslint v4, update eslint-config-airbnb-base 2017-09-02 10:24:51 -07:00
Jordan Harband
1f5ca4c976 [eslint config] [base] v12.0.0 2017-09-01 22:57:11 -07:00
Jordan Harband
63d1ae175e [Tests] fix linting error caused by updated base config 2017-09-02 09:04:05 -07:00
Jordan Harband
9d91990221 [Tests] stop testing on eslint v3 2017-09-01 22:59:54 -07:00
elmehri
b687a9ceb8 [eslint config] [base] [patch] support Protractor config files in import/no-extraneous-dependencies 2017-08-29 15:27:08 +01:00
Tonni
18255d14d4 [guide] Add documentation for exponentiation operator (**). 2017-06-26 23:00:26 +08:00
Jordan Harband
55219bfdcf v11.3.0 2017-07-23 13:08:57 -07:00
Jordan Harband
811392725e [Deps] allow eslint v3 or v4; update eslint-plugin-import
Part of #1447.
2017-07-23 11:35:51 -07:00
Jordan Harband
399420f46f [Tests] add an explicit eslint version to travis.yml 2017-07-23 10:39:12 -07:00
Jordan Harband
b4995b6416 [eslint config] [base] revert breaking part of #1420
I’ll re-enable it in the next major.
2017-07-23 13:04:22 -07:00
Chris Atkin
cdc1c4fb76 [inthewild] Add Sainsbury's Supermarkets to the organizations list 2017-07-23 14:30:32 +01:00
Chaitanya Mutyala
6331c2c3e2 [guide] Typo fix on example 2017-07-12 10:43:11 -07:00
Valentina Pegler
22c97fa678 [inthewild] Add LEINWAND to the organizations list 2017-07-12 18:12:38 +02:00
Jordan Harband
fc7fae620f [Tests] add pretravis/posttravis scripts 2017-07-04 16:15:18 -07:00
Jordan Harband
7768e01625 [eslint config] [*] Add missing rules 2017-07-04 14:30:29 -07:00
Jordan Harband
e5b403cd49 [eslint config] [base] [deps] update babel-preset-airbnb, eslint-find-rules, eslint-plugin-import, tape 2017-07-04 14:36:47 -07:00
Jordan Harband
d806859320 [Tests] run prepublish tests as allowed failures 2017-07-04 12:49:09 -07:00
Jordan Harband
c68fa63262 [eslint config] v15.0.2 2017-07-04 12:36:18 -07:00
Jordan Harband
8448706120 [eslint config] [deps] update babel-preset-airbnb, eslint-find-rules, eslint-plugin-import, eslint-plugin-jsx-a11y, eslint-plugin-react, tape 2017-07-04 12:32:01 -07:00
Dan Dascalescu
2666db559d Fix typo in a11y for yarn 2017-06-23 22:16:35 -07:00
Dan Dascalescu
cd720b4c7b [eslint config] [*] [docs] add yarn instructions
Fixes #1462.
2017-06-22 09:19:08 -07:00
Jason Ellis
4380284b05 [guide] Add missing close parenthesis and semicolon to section 8.2 2017-06-20 09:37:19 -05:00
Jordan Harband
57ff032b07 [eslint config] [base] [minor] no-return-assign: strengthen linting against returning assignments. 2017-06-18 09:27:33 -07:00
elmehri
3a9e1c830f [eslint config] [base] [patch] Support Protractor config files in import/no-extraneous-dependencies 2017-06-15 16:52:48 +01:00
Rahul Gandhi
0c9e22e039 [guide] replacing undefined with ReferenceError
Fixes #1457
2017-06-17 18:18:40 +05:30
Ben Schroeder
7bb8c9f905 [guide] Fix iterator code example error
The first "good" example was missing a closing bracket (line 1377).
2017-06-14 09:13:43 -04:00
Jordan Harband
cd4ec6245e [guide] change more straight quotes to curly quotes 2017-06-14 12:09:46 -07:00
Felipe Vargas
4499ee0094 [guide] No arrow function implicit return with side effects 2017-06-12 15:41:11 -07:00
Fernando Pasik
c43fc749c4 [eslint config] [docs] Remove TODO in prefer-reflect as it's deprecated 2017-06-13 22:06:55 +01:00
Jordan Harband
fd8cbec8e0 [guide] change straight quotes to curly quotes 2017-06-13 01:06:34 -07:00
Gustavo Isensee
1bbac74286 Updated "how to define propTypes..."
Imported from new prop-types module.
2017-06-13 00:59:43 -03:00
Radu Serbanescu
00c9e52aec [eslint config] [base] [minor] Balanced spacing for inline block comments
Fixes #1425.
2017-06-07 13:18:38 +03:00
Jordan Harband
721af5498f [Tests] on node v8 2017-06-03 23:39:24 -07:00
Jordan Harband
1a38734d63 [Tests] npm v4.6+ breaks in node < v1; npm 5+ breaks in node < v4 2017-06-03 23:38:22 -07:00
Jordan Harband
5ba31498fe Only apps should have lockfiles. 2017-06-03 23:37:13 -07:00
Daniel Axelrod
98f2224ec2 Add linting for Markdown prose
Codify existing practices for writing Markdown in style guides and
enforce them via Markdownlint. A new npm script "lint" in the top level
package.json runs before tests or as the first step of the "travis"
script.

Only modify documents in cases where they had bugs or isolated cases of
inconsistency:

README.md: 10: MD007 Unordered list indentation
Inconsistent with all other top level lists

README.md: 10: MD032 Lists should be surrounded by blank lines
Some Markdown parsers don't handle this correctly

README.md: 3156-3161: MD005 Inconsistent indentation for list items at
                      the same level
Bug, looks like it's intended to be another list level but GitHub
renders it at the same level as the "No but seriously"

README.md & css-in-javascript/README.md: throughout: MD012 Multiple
          consecutive blank lines

README.md: throughout: MD004 Unordered list style
Some nested lists used plusses, now everything consistently uses
dashes.
2017-06-02 17:10:16 +00:00
Joe Lencioni
ac6de2fdb8 Bump copyright year 2016 -> 2017 in license 2017-06-02 12:05:41 -07:00
Ken Powers
f3c9639abe [eslint config] [base] [patch] Allow jsx extensions for test files 2017-05-24 15:43:56 -04:00
Daniel Axelrod
0f8f30dcd0 [6.5] Add no-eval eslint rule to docs
Add reference to the eslint `no-eval` rule to the README.

This rule is already set to `error` in best-practices.js in eslint-airbnb-config-base.
2017-05-24 01:13:26 +00:00
Jordan Harband
44ca3c2b3a [eslint config] [deps] update eslint-plugin-jsx-a11y 2017-05-23 12:54:02 -07:00
Jordan Harband
f86aacae44 [eslint config] [fix] jsx should be enabled via parserOptions, not via a root ecmaFeatures.
From https://github.com/airbnb/javascript/issues/1410#issuecomment-303368921
2017-05-23 12:53:26 -07:00
Siddharth Doshi
0dd3dbd7b6 [eslint config] [base] [breaking] Blacklist confusing globals 2017-05-20 15:41:37 +05:30
Vlad Shcherbin
324bf9c834 Fix option typo 2017-05-19 15:04:22 +03:00
Jordan Harband
8cabe49b94 [eslint config] v15.0.1 2017-05-15 17:54:47 -07:00
Billy Janitsch
fe65e4b649 [eslint config] [patch] Fix reported React version
Fixes #1414.
2017-05-15 12:39:37 -04:00
Jordan Harband
58e6cd323a [eslint config] v15.0.0 2017-05-14 17:05:45 -07:00
Jordan Harband
0449d9b571 [eslint config] [deps] update eslint-config-airbnb-base 2017-05-14 16:58:38 -07:00
Jordan Harband
d48083796c [eslint config] [base] v11.2.0 2017-05-14 16:53:50 -07:00
Siddharth Doshi
5bcb840abe [eslint config] [base] [minor] Disallow unused global variables 2017-05-12 01:08:33 +05:30
Jordan Harband
655886fc87 [eslint config] [deps] update eslint-plugin-react 2017-05-13 14:12:21 -07:00
Jordan Harband
152eaa6669 [guide] [react] Update React README ref to jsx-a11y/jsx-space-before-closing 2017-05-09 10:39:35 -07:00
Trevor Sayre
2f912c1dd3 [guide] [react] Update React README ref to jsx-a11y/img-has-alt
https://github.com/evcohen/eslint-plugin-jsx-a11y/pull/220
2017-05-09 13:12:09 -04:00
Jordan Harband
18e5ac9a8c [eslint config] [deps] update eslint-plugin-jsx-a11y 2017-05-09 10:30:16 -07:00
Jordan Harband
d469bb25c1 [eslint config] [deps] [breaking] update eslint-plugin-react
- enable `react/no-will-update-set-state`
 - delete removed rules
 - `jsx-wrap-multilines`: enable `arrow` option
 - `jsx-first-prop-new-line`: change to `multiline-multiprop`
 - disable `jsx-space-before-closing` in favor of `jsx-tag-spacing`
2017-05-05 23:52:17 -07:00
Jordan Harband
01e3977597 [eslint config] [breaking] enable rules:
- `no-autofocus`: enable `ignoreNonDOM`
 - add options to `no-static-element-interactions`

 - remove `onclick-has-role`

 - add `alt-text` (replaces `img-has-alt`)
 - add `interactive-supports-focus` (replaces `onclick-has-focus`)

 - add `no-noninteractive-element-interactions`
 - add `media-has-caption`
 - add `no-interactive-element-to-noninteractive-role`
 - add `no-noninteractive-element-to-interactive-role`
 - add `no-noninteractive-tabindex`
2017-05-05 12:34:00 -07:00
Jordan Harband
121a95d715 [eslint config] [deps] [breaking] update eslint-plugin-jsx-a11y 2017-05-05 12:16:58 -07:00
Thomas Grainger
f878edad25 [eslint config] [base] [patch] also disallow padding in classes and switches 2017-05-05 11:42:43 +01:00
Jordan Harband
5aa203eaa8 [eslint config] [base] [deps] [breaking] require eslint v4
- enable `function-paren-newline`, `for-direction`, `getter-return`, `no-compare-neg-zero`, `semi-style`, `object-curly-newline`, `no-buffer-constructor`, `no-restricted-globals`, `switch-colon-spacing`, `template-tag-spacing`, `prefer-promise-reject-errors`, `prefer-restructuring`
 - improve `indent`, `no-multi-spaces`, `no-trailing-spaces`, `no-underscore-dangle`
2017-09-01 22:25:31 -07:00
David Walsh
f5cd2869d3 [guide] [eslint config] [base] [breaking] Rules prohibiting global isNaN, isFinite.
- Update README with new Standard Library section.
2017-07-04 12:40:53 +10:00
koooge
5dec8272e0 [eslint config] [base] [breaking] move comma-dangle to Stylistic Issues 2017-08-03 17:57:58 +02:00
Jordan Harband
7cef8dad84 [eslint config] [docs] add rule documentation to forbid-elements entry 2017-05-01 12:31:57 -07:00
Jordan Harband
ba35e31c76 [eslint config] [breaking] set default React version to 0.15 2017-05-01 12:22:41 -07:00
Jordan Harband
c9c5f7efbf [eslint config] [minor] enable rules:
- `jsx-max-props-per-line`
 - `void-dom-elements-no-children`
2017-05-01 12:22:24 -07:00
Jordan Harband
bfc85bddba [eslint config] [deps] update eslint-config-airbnb-base, eslint 2017-05-01 12:21:54 -07:00
thomas Bell
3ca86a4a3c added generation tux as in the wild 2017-05-03 14:16:32 -04:00
Vlad Shcherbin
b87cb5cdad [guide] [Fix] react/prefer-stateless-function "ignorePureComponents" option typo 2017-05-01 10:57:49 +03:00
Martin Veith
275d4bba98 Add "Control statements" section 2017-05-01 11:11:31 +02:00
Jordan Harband
ee6b23d862 [guide] remove remaining numbered links used as targets. 2017-04-30 21:19:58 -07:00
Denis Izmaylov
3fe99604e6 Add 'Axept' into 'In the Wild' section 2017-04-29 18:20:56 +03:00
Diego Teliz
83711e089a Add 'InterCity Group' on 'In the Wild' list 2017-04-27 15:03:28 +12:00
Joe Lencioni
17917eedfb Merge pull request #1388 from airbnb/dubin-remove-simply-base
Remove "simply" from Readme in base
2017-04-25 10:51:08 -07:00
Jonathan Dubin
1997f8ee85 Remove "simply" from Readme in base 2017-04-25 10:47:50 -07:00
Joe Lencioni
c2d9fd7762 Merge pull request #1387 from airbnb/dubin-remove-simply
Remove "simply" from Readme
2017-04-25 10:41:48 -07:00
Jonathan Dubin
88a070cd0d Remove "simply" from Readme 2017-04-25 10:37:54 -07:00
Nicolas Jakob
7abd9a929c Add rollup.config.*.js to import/no-extraneous-dependencies ignore list 2017-04-24 16:24:54 +02:00
Martin Veith
8eee1f1b69 [guide] [react] Add missing semicolons 2017-04-22 18:16:18 +02:00
Thomas Rix
71932e1eed [eslint config] Turn ignorePureComponent option on for react/prefer-stateless-function
Otherwise, there is no way to write pure components that don't use state, refs, or lifecycle methods.

Stateless functions are not treated internally as pure components, and are rerendered every time.
2017-04-20 16:51:02 -04:00
Joe Lencioni
07d37db67a Merge pull request #1370 from hanzhijue/patch-1
Fix the example of "propTypes"
2017-04-12 07:17:10 -07:00
Kaka
2c0da30904 Fix the example of "propTypes"
This example makes me confused. I guess it missed the use of "children" of good code.
Is the example to explain that you should specify default values for non-required props?

Thanks
2017-04-12 16:43:12 +08:00
Jordan Harband
54be49ab7d Merge pull request #1368 from bl00mber/master
[docs] translation links sorted and updated
2017-04-11 14:26:03 -07:00
Nikita
462ea7dd0a translation links in react guide updated 2017-04-12 02:05:40 +05:00
Nikita
cb027cd002 translation links sorted 2017-04-12 02:01:16 +05:00
Max Kaplan
fa0a82373e adding sourcetoad to users 2017-04-04 09:52:16 -04:00
Jordan Harband
e43bdd98d5 [eslint config] [base] v11.1.3 2017-04-03 15:44:14 -07:00
Jordan Harband
74071a809c [eslint config] [base] [patch] add error messages to no-restricted-syntax
Fixes #1353.
2017-04-03 15:23:00 -07:00
Jordan Harband
aa9bbf9f49 [eslint config] [base] [deps] update eslint 2017-04-03 15:22:34 -07:00
Jordan Harband
b8d8d6e56f [eslint config] [deps] update eslint-config-airbnb-base, eslint, eslint-plugin-react 2017-03-25 21:32:09 -07:00
Jordan Harband
75d48c7570 [eslint config] [base] v11.1.2 2017-03-25 18:43:29 -07:00
Jordan Harband
ae1c919cd4 [eslint config] [base] [deps] update eslint 2017-03-25 18:40:06 -07:00
Jaden Dessureault
98f1b19d95 Indent blockquotes in markdown guides
This is required to make sure all code blocks have proper syntax highlighting
2017-03-22 19:55:14 -05:00
Hugo
13dc420a9e Fix Gitter badge in README.md 2017-03-21 12:46:21 +11:00
JPeer264
5797f545d8 [guide] Add array-bracket-newline (close #1338) 2017-03-17 08:48:43 +01:00
Jordan Harband
321fb271bd [eslint config] [*] [deps] update eslint 2017-03-15 18:03:56 -07:00
Christian Bundy
34752644c3 [eslint config] [base] Add ignorePropertyModificationsFor 2017-03-15 14:27:08 +00:00
Jordan Harband
772bbb5b7d [eslint config] [base] [deps] update eslint 2017-03-03 15:08:41 -08:00
Jordan Harband
f9aff60f53 [eslint config] [deps] update eslint, eslint-config-airbnb-base 2017-03-03 14:14:46 -08:00
Jordan Harband
be0315eda1 [eslint config] [base] v11.1.1 2017-03-03 13:35:36 -08:00
Jordan Harband
1f5999b2ed [eslint config] [base] [deps] update eslint
- fill out options in `no-use-before-define`
 - enable `ignoreRestSiblings` in `no-unused-vars`
2017-03-03 13:33:24 -08:00
Ivan Zusko
1a2edb9e9e Add ukrainian translation 2017-01-04 10:58:43 +02:00
David Cameron
c9490c698e [guide] Added 'let' to rule defs regarding variables 2017-03-03 14:44:34 -05:00
Tom Wrenn
93e91d3eb9 Add AltSchool to the "In The Wild" section of the README 2017-03-03 11:36:09 -08:00
Tihomir Opacic
5ad25766fb Added OHD to a list of style guide users. 2017-03-01 20:31:43 +01:00
Harrison Shoff
5ca6d46b7c [resources] add link to neutrino preset
https://neutrino.js.org/presets/neutrino-preset-airbnb-base/
2017-02-25 14:12:37 -08:00
Raj Nigam
b153231867 Update renamed jsx-wrap-multilines
`react/wrap-multilines` has been renamed to `react/jsx-wrap-multilines`
2017-02-23 11:36:24 -05:00
Steve Mao
bc21501cc7 [eslint config] [base] [minor] add **/*.spec.js as a test files pattern
(see #1131)
2017-02-23 14:13:39 +11:00
Adam Walsh
840d021d07 Add Honey to list of users 2017-02-22 10:08:38 -08:00
Jordan Harband
bbbabf32f8 [eslint config] [deps] update eslint-plugin-react
- semver-patch: `jsx-max-props-per-line` “when” set to “multiline”, but left off for now.
2017-02-19 16:59:00 -08:00
Joe Lencioni
7152396219 Merge pull request #1303 from airbnb/lencioni-patch-1
Add link to Mixins section in TOC
2017-02-14 11:44:19 -08:00
Joe Lencioni
d23b442799 Add link to Mixins section in TOC
I forgot this when I created the section.
2017-02-14 10:46:19 -08:00
Joe Lencioni
3bbbf6d498 Merge pull request #1302 from airbnb/mixins
Add guidance around not using mixins
2017-02-14 10:44:51 -08:00
Joe Lencioni
1841d2fb99 Add guidance around not using mixins
Mixins will hopefully be removed from React eventually. In the meantime,
we can avoid the damage they cause by not using them. Most of this was
borrowed from @gaearon's blog post "Mixins Considered Harmful".

https://facebook.github.io/react/blog/2016/07/13/mixins-considered-harmful.html
2017-02-14 10:31:45 -08:00
Josh Duck
8cab89e792 Add note to explain what a soft tab is
A quick Google search shows that the name "soft tab" causes some confusion. Added a brief clarification.
2017-02-14 10:44:25 +10:00
Sota Yamashita
c29e615be4 [inthewild] remove deleted repositories 2017-02-12 12:13:35 +09:00
nprescott
ec42fbecbf [guide] README update for JSCS deprecated links 2017-01-22 11:11:08 -05:00
Jordan Harband
2c390ecea9 [eslint config] [breaking] update eslint-plugin-jsx-a11y to v4, enable new rules 2017-02-05 14:00:41 -08:00
Colin Hamer
6435f8ff23 [inthewild] Adds CaseNine 2017-02-09 10:16:00 +01:00
Jordan Harband
7e35c2dbfc [eslint config] v14.1.0 2017-02-05 13:07:53 -08:00
Jordan Harband
a8ecaa8a5a [eslint config] [deps] [patch] allow eslint-plugin-jsx-a11y to be v3 or v4. Remove no-marquee rule temporarily. 2017-02-05 10:50:34 -08:00
Jordan Harband
de5cd510b8 [eslint config] [deps] update eslint-config-airbnb-base, babel-preset-airbnb, eslint 2017-02-05 10:43:32 -08:00
Jordan Harband
b6fc6dc7c3 [eslint config] [base] v11.1.0 2017-02-05 10:31:04 -08:00
Jordan Harband
a8d2f94884 [eslint config] [base] update eslint, babel-preset-airbnb 2017-02-05 10:28:13 -08:00
Eric Martin
4d024be5a4 [guide] Added documentation for arrow function parens with one arg
Added explanation for using parentheses with explicit returns and alternatives with the eslint "always" option.
2017-02-02 19:13:13 -05:00
Robin Pokorný
9375fb59b3 [guide] Use const when not reassigning reference 2017-02-02 13:31:10 +01:00
Florian Berger
e22f02cda3 Update React link in organizations 2017-02-01 19:22:34 +02:00
Florian Berger
897b8fcc1c Change function order in functions (7.1) example
Part 7.1 says first why function declarations are not good and
after that it recommends to give a name to function expression.
The same order could be used in example too.
2017-02-01 18:34:02 +02:00
Jordan Harband
d0fb7635bc [eslint config] [base] enable no-multi-assign 2017-01-20 13:45:50 -08:00
Jordan Harband
62a1edecdb [eslint config] [base] [deps] update eslint 2017-01-20 13:44:25 -08:00
Andrey Mereskin
7b7ffc533d Merge pull request #1269 from leonidlebedev/master
Update russian translation
2017-01-20 21:28:41 -08:00
Leonid Lebedev
8e12091e8f [guide] Update russian translation 2017-01-18 21:00:35 +03:00
Vse Mozhet Byt
cb32f443c9 [guide] fix arrow IIFE call
Currently, it throws.
2017-01-18 07:42:53 +02:00
Vse Mozhet Byt
6e4859d7c6 [guide] remove trailing or leading underscores 2017-01-18 07:33:11 +02:00
Vse Mozhet Byt
231317408f [guide] add trailing commas 2017-01-18 07:27:18 +02:00
Vse Mozhet Byt
9bb29860bc [guide] add spaces 2017-01-18 07:17:30 +02:00
Vse Mozhet Byt
9fdd6d6ffa [guide] add / remove semicolons 2017-01-18 07:15:57 +02:00
Vse Mozhet Byt
d9284873a8 [guide] const -> let 2017-01-18 07:10:09 +02:00
Vse Mozhet Byt
ee492a73ba [guide] comment out ellipses 2017-01-18 07:06:04 +02:00
Vse Mozhet Byt
41fa95eef9 [guide] fix indentation for consistency 2017-01-18 07:02:56 +02:00
Vse Mozhet Byt
d8c3048f24 [guide] ``js -> ``javascript for consistency 2017-01-18 06:56:07 +02:00
Harkirat Saluja
40d5797b35 [guide] [react] Add missing trailing comma 2017-01-17 14:59:41 +05:30
Irving Barajas
cdbe705fc4 [inthewild] Adds SwoopApp 2017-01-18 18:32:23 -08:00
Christian Oliff
a6a6f4b488 Update copyright year 2017-01-17 17:09:27 +09:00
Olivier Tassinari
b06c5c6621 Avoid octal number interpretation
Some JavaScript versions interpret numbers as octal if they are written with a leading zero.
Babel interpreter throws with an `Invalid number` message.
2017-01-15 12:39:30 +01:00
oshalygin
712e010f29 Update common function body comment
- This commit provides a canonical way of describing
  that the function body contains code of some sort.
- The convention chosen was '// ...'.
- This change is persisted throughout the readme file
  where appropriate
2017-01-11 15:36:59 -08:00
Greg Werner
73e27ef036 add 3blades reference 2017-01-10 23:27:55 -05:00
Wooram Jun
d892cc9117 [eslint config] [base] Update a deprecated option 2017-01-10 20:39:34 +09:00
Jeff Cousins
b7aabb938d Add semicolon to named function expression variable declaration 2017-01-09 17:10:10 -06:00
Ivan Zusko
2df021eb83 [guide] [react] Added React/JSX Style Guide in Ukrainian 2017-01-04 10:58:43 +02:00
Jordan Harband
846d687936 [eslint config] v14.0.0 2017-01-08 15:19:26 -08:00
Jordan Harband
7ec81d2a94 [eslint config] [deps] update eslint, eslint-plugin-react, eslint-config-airbnb-base 2017-01-08 15:11:50 -08:00
Jordan Harband
7963b97438 [eslint config] [base] v11.0.1 2017-01-08 15:00:08 -08:00
Jordan Harband
7e865a4e8a [eslint config] [base] [deps] update eslint 2017-01-08 14:55:09 -08:00
Ricardo Ambrogi
097047202e [guide] fix Array name in examples 2017-01-08 11:19:15 -02:00
nathanhleung
266860b597 [eslint config] [*] [docs] add note about install-peerdeps
Closes #1233.
2017-01-06 17:04:28 -05:00
Kamron Batman
b48438141c [inthewild] Adds BashPros 2016-12-28 12:53:51 -08:00
Felix Sanz
6593964080 Fixed Functions (7.1) JSCS rule 2016-12-29 02:25:03 +01:00
Kamron Batman
c6b7c9ef94 [eslint config] [*] [deps] update eslint, eslint-plugin-jsx-a11y 2016-12-28 11:57:14 -08:00
Maxim Samoilov
b7cc2dc89f [docs] Fix package name in eslint-config-airbnb-base 2016-12-25 06:27:52 +03:00
Giang Nguyen
c9edc92a80 [guide] update vietnamese translation link 2016-12-23 18:24:50 +07:00
Pedro Pablo Aste Kompen
6eacbc2aad [guide] Fix chaining example to be consistent with string interpolation 2016-12-21 16:06:56 -03:00
woojoo666
019a6edaaa [eslint config] [*] [docs] Updated instructions to support non-bash users 2016-12-19 07:24:50 -08:00
Simen Bekkhus
c30adcc60d Add editorconfig 2016-12-14 08:57:11 +01:00
David Knaack
e947cace2c [eslint config] [base] [patch] add gulpfile.*.js to import/no-extraneous-dependencies
Otherwise e.g. gulpfile.babel.js won't be matched
2016-12-12 17:49:00 +01:00
Jordan Harband
24f004027b [eslint config] [*] [deps] update eslint 2016-12-12 14:33:55 -08:00
Jordan Harband
e1a307ae0a [eslint config] [breaking] enable react/no-array-index-key, react/require-default-props 2016-12-11 23:25:40 -08:00
Jordan Harband
6c4456d354 [eslint config] [deps] update eslint, eslint-plugin-react, tape, eslint-config-airbnb-base 2016-12-11 23:25:03 -08:00
Jordan Harband
b178cf9be0 [eslint config] [base] v11.0.0 2016-12-11 23:09:49 -08:00
Jordan Harband
4a005b1322 [eslint config] [base] disable no-duplicate-imports rule - obsoleted by import/no-duplicates.
Closes #1188. Closes #1195. Closes #1054.
2016-12-11 23:07:36 -08:00
Jordan Harband
e037d29b93 [eslint config] [base] [deps] [breaking] update eslint; enable no-await-in-loop 2016-12-11 10:44:37 -08:00
Arturo Pie
898a70e7fe [inthewild] Add Nulogy (https://nulogy.com/) 2016-12-11 11:42:07 -05:00
Eric Churchill
4d68ddc4bb Change "modified" to "increasedByOne" to minimize ambiguity 2016-12-10 23:17:10 -08:00
Sara Gudeman
1df98256d0 [guide] add map example to iterators 2016-12-09 11:29:03 -08:00
Kevin Boudot
a56f239b95 [inthewild] Add Bonhomme 2016-12-08 15:29:06 +01:00
alejandro garcia
243d824fb4 [guide] [react] Added react jsx guide in spanish 2016-12-07 19:19:54 +01:00
Jordan Harband
0b3b5a178f [eslint config] [base] [deps] update eslint, tape 2016-12-06 01:58:13 -08:00
soulchainer
780be0dcd9 [guide][react] Add missing parenthesis in «Refs» recommendation
As is, actual «good» usage fires the arrow-parens rule.
Parenthesis are needed to follow the current style guide.
2016-12-04 02:11:48 +01:00
Joe Lencioni
664877a601 Avoid i++ in array spreads example
This style guide recommends using `i += 1` over `i++`. Even though this
appears in a "bad" example, the example will be clearest if it is "bad"
in fewer ways.
2016-12-01 09:11:00 -08:00
Giuseppe Burtini
54aa8f1b35 [guide] Fix no-interpolation template string example
The example showed a template string being used with no interpolation as "good". While it met the rule being described, it violated another rule for no reason.
2016-08-29 08:16:34 -07:00
Jordan Harband
1ab6aaede9 [eslint config] [*] [deps] update eslint, eslint-plugin-react 2016-11-18 10:39:38 -08:00
Jordan Harband
f3f7124fcc [eslint config] [base] [patch] import/no-extraneous-dependencies: add some comments to ignore patterns. 2016-11-14 17:58:12 -08:00
Andrey Polischuk
97da1f0f9d [eslint config] [base] [patch] add import/no-extraneous-dependencies ignore patterns for test files
Fixes #1174
2016-11-12 14:32:05 +03:00
Jordan Harband
25d03b8b67 [eslint config] [*] [breaking] [deps] update eslint, eslint-plugin-import, eslint-plugin-react 2016-11-14 13:52:26 -08:00
ViZhe
72eb3e443e [eslint config] [breaking] [deps] update eslint-plugin-jsx-a11y to v3 2016-11-08 19:35:36 +03:00
Jordan Harband
b73649925a [guide] [react] add note that defaultProps must always be provided for non-required props 2016-11-09 22:53:09 -08:00
C. T. Lin
ec08ca84ba [eslint config] [base] import/no-extraneous-dependencies: added ignore patterns for config files
Fixes #1168
2016-11-09 12:46:11 +08:00
Jordan Harband
ae1c0f89cb [eslint config] [deps] update eslint-config-airbnb-base 2016-11-07 01:01:15 -08:00
Jordan Harband
f82857512d [eslint config] [base] v10.0.1 2016-11-07 00:49:02 -08:00
Jordan Harband
a2cb4a2cd6 [eslint config] [base] [fix] legacy config should not require **
Per 1399b3cbfa (commitcomment-19718532)
2016-11-07 00:48:12 -08:00
Pete Pirasis
97575b2087 Fix broken rule reference link import/first 2016-10-27 03:04:31 +07:00
Jordan Harband
24b8f35f18 [eslint config] v13.0.0 2016-11-06 22:14:05 -08:00
Jordan Harband
3e656750e6 [eslint config] [breaking] re-enable react/no-unused-prop-types 2016-11-06 22:07:50 -08:00
Jordan Harband
c3044f811e [eslint config] [breaking] [deps] update eslint-config-airbnb-base, eslint, eslint-plugin-import, eslint-plugin-react 2016-11-06 16:02:50 -08:00
Spen Taylor
38bd170e2c [guide] Update syntax in eol-last examples 2016-11-07 10:39:00 +11:00
Jordan Harband
8c2df7493a [eslint config] [base] v10.0.0 2016-11-06 10:41:38 -08:00
Jordan Gensler
9f51fd264b [guide] Add notes on acronyms and initialisms to naming 2016-11-06 10:46:15 -08:00
Jordan Harband
c4a9d28485 [Tests] on node v7 2016-11-06 10:34:35 -08:00
Jordan Harband
2f9dddbe20 [eslint config] [base] [patch] loosen no-extraneous-dependencies for test files.
Relates to #959, #1089.
2016-11-06 10:01:36 -08:00
Jordan Harband
1399b3cbfa [eslint config] [base] [breaking] prefer ** over Math.pow 2016-11-06 09:54:42 -08:00
Jordan Harband
436cf3ee63 [eslint config] [base] [breaking] update eslint, eslint-plugin-import; enable import/no-named-default 2016-11-06 09:54:17 -08:00
Andrew Smith
3ab19f07f4 [guide] Fix inconsistency in function expression rules. 2016-10-25 14:47:25 -07:00
Jonathan Chen
153c02b36c Create LICENSE.md 2016-11-01 06:31:17 -04:00
Jonathan
535cb799a9 [guide] Mention both num++ and num ++ 2016-11-02 16:02:35 +01:00
Mark Miyashita
556846745c [guide] Separate 19.2 code blocks into diff + javascript sections 2016-11-06 05:19:22 -08:00
Ryan Busby
86f52012cd [guide] quotes: corrected casing
Updated case to read the same in multiple spots. Added single quote example
2016-11-02 20:13:59 -07:00
Thomas Grainger
7882082954 [eslint config] [base] [breaking] comma-dangle: require trailing commas for functions 2016-11-02 00:56:01 -07:00
Jordan Harband
c51251d17b [guide] add section on multiline function signatures/invocations 2016-11-02 00:48:11 -07:00
Kevin Grandon
f9a5dd4919 Update JSX quote style rationale.
Based on https://github.com/airbnb/javascript/issues/629#issuecomment-166384924.
2016-11-01 13:54:07 -07:00
Jordan Harband
017dfa81fa [Docs] add reference to spaced-comment rule; flesh out options 2016-10-31 21:36:28 -07:00
Nischay Venkatram
9cbda0f0e7 Updated README - Added sub-section for spaces in comments 2016-10-31 18:38:36 -05:00
Gianfrancø Palumbo
fbfe8812ee DailyJS is not longer being published 2016-10-31 23:55:24 +00:00
dan-h-ch
4acb48b09a Updated README.md - Corrected capitalize on GitHub 2016-10-31 12:22:40 -07:00
Jordan Harband
5aec2c6691 [eslint config] [base] correct another typo from a23a3efba9 2016-10-31 02:22:30 -07:00
Jordan Harband
f3878876d2 [eslint config] [deps] update eslint 2016-10-31 02:09:09 -07:00
Jordan Harband
5da6fac8cc [eslint config] [base] correct typo from a23a3efba9 2016-10-31 02:01:37 -07:00
Jordan Harband
9b649c843f [eslint config] [*] [dev deps] update eslint-find-rules 2016-10-31 01:37:23 -07:00
Jordan Harband
a23a3efba9 [eslint config] [base] [deps] [breaking] update eslint
- enable `no-useless-return`
 - tighten up `indent`
 - loosen `max-len` with `ignoreRegExpLiterals` option
2016-10-31 01:36:15 -07:00
Pete Pirasis
05d0634627 Add reference for Object.assign 2016-10-27 03:31:58 +07:00
Pete Pirasis
adc782343e [react] add rule references in section *Spacing* 2016-10-27 01:58:42 +07:00
SpenUK
0e2b74a263 Add links to mentioned github issues 2016-10-26 16:45:32 +11:00
Jordan Harband
70428bdc37 [eslint config] [*] [deps] update eslint 2016-10-22 01:04:16 -07:00
Jordan Harband
a06831d52c [eslint config] [patch] set react/no-unused-prop-types to “warn”, pending bugfixes.
Closes #1099.
2016-10-22 01:03:16 -07:00
Jordan Harband
0bb3eb5412 [eslint config] [deps] [breaking] update eslint-config-airbnb-base, eslint-plugin-import 2016-10-16 23:20:02 -07:00
Jordan Harband
d7d50bcbd0 [eslint config] [base] v9.0.0 2016-10-16 23:16:28 -07:00
Simen Bekkhus
a1ca49b34c Add ForOfStatement to no-restricted-syntax
Fixes #1122
2016-10-17 08:04:38 +02:00
Simen Bekkhus
9c5afe5809 Update eslint to 3.8.0
New rule called `func-name-matching` added
2016-10-16 18:58:18 +02:00
Mikael Finstad
978c0eecc2 Use import instead of require
Don't recommend the use of require
(See 10.1)
2016-10-16 16:59:23 +02:00
Jordan Harband
a75efdfdb0 [guide] improve ++/-- example.
Fixes #1130.
2016-10-14 22:37:14 -07:00
Jordan Harband
baa831b4a9 [eslint config] [*] [docs] ensure latest version of config is installed
Fixes #1121.
2016-10-13 10:26:31 -07:00
Jordan Harband
8d0fda975c [eslint config] [base] Add comments on new import rules. 2016-10-13 00:40:14 -07:00
Simen Bekkhus
b59bfffac3 Enable import/no-webpack-loader-syntax rule 2016-10-13 09:09:10 +02:00
Jordan Harband
eb9927fb58 [eslint config] [deps] update eslint-plugin-react 2016-10-12 23:50:56 -07:00
Simen Bekkhus
b599b7c2d5 Upgrade to import plugin v2 2016-10-11 18:37:09 +02:00
Miles Burton
357cc46da0 Update README.md
Minor oversight generating map object. Need square brackets to generate dynamic key.
2016-10-11 08:44:43 +01:00
Jordan Harband
781f186f90 [eslint config] [*] [deps] update safe-publish-latest, eslint-plugin-jsx-a11y, eslint-plugin-react 2016-10-09 20:33:06 -07:00
Chester How
1483292893 Fix naming typo 2016-10-10 11:21:18 +08:00
Randall Reed, Jr
b7492ffe60 Update comparison recommendation
* Use shortcuts for boolean comparisons
* Use explicit comparisons for strings and numbers
2016-10-08 16:41:45 -04:00
Randall Reed, Jr
d0d260095b Make section numbering consistent
* Renumber items where numbers were skipped
2016-10-08 13:01:54 -04:00
Jordan Harband
1bc2f3f365 Merge pull request #1110 from karanjthakkar/multiline-imports
[guide] Add section on multiline imports.

Fixes #1051
2016-10-07 00:19:12 -07:00
Karan Thakkar
b72bd520b6 Fix rule description 2016-10-07 12:34:36 +05:30
Karan Thakkar
098894efee Remove legacy anchor link. Add dangling comma 2016-10-07 12:16:21 +05:30
Karan Thakkar
6ad315c090 Add section on multi-line imports. Fixes #1051 2016-10-06 14:54:53 +05:30
Jordan Harband
e2de71efb7 [eslint config] [*] update babel-preset-airbnb, eslint, eslint-find-rules, tape 2016-10-03 16:15:31 -07:00
jcreamer898
8468ed8423 Lonely Planet
Add Lonely Planet to the "In the Wild" list.
2016-09-27 09:13:20 -05:00
Tim van der Horst
24223ee444 [eslint config] [patch] class-methods-use-this: exempt React getChildContext
Added `getChildContext` to the exceptions list for `class-methods-use-this`
2016-09-27 18:07:56 +10:00
Jonas Enlund
59db4aab15 [eslint config] [base] [patch] new-cap: add immutable.js exceptions 2016-09-25 11:56:54 +03:00
Jordan Harband
a1c84eee15 [eslint config] v12.0.0 2016-09-24 15:06:10 -07:00
Jordan Harband
39d7c73ef1 [eslint config] [patch] class-methods-use-this: exempt React lifecycle methods 2016-09-24 20:03:58 -07:00
Jordan Harband
976845e930 [eslint config] [breaking] Enable react rules:
- `react/no-unescaped-entities`
 - `react/no-children-prop`
2016-09-24 14:38:54 -07:00
Jordan Harband
0dae56a8e1 [eslint config] [patch] disable deprecated and redundant react/require-extension rule
Fixes #978.
2016-09-24 14:34:52 -07:00
Jordan Harband
0faabe054d [eslint config] [breaking] [deps] update eslint-config-airbnb-base 2016-09-24 14:30:57 -07:00
Jordan Harband
0157e69a0d [eslint config] [base] v8.0.0 2016-09-24 12:31:53 -07:00
Jordan Harband
f6dab799b8 [eslint config] [base] [breaking] enable rules:
- `no-restricted-properties`
 - `prefer-numeric-literals`
 - `lines-around-directive`
 - `import/extensions`
 - `import/no-absolute-path`
 - `import/no-dynamic-require`
2016-09-24 12:30:58 -07:00
Jordan Harband
173cba3cc6 [eslint config] v11.2.0 2016-09-23 22:45:47 -07:00
Jordan Harband
62cac3eea1 [eslint config] [deps] update eslint-config-airbnb-base 2016-09-23 22:42:53 -07:00
Jordan Harband
ec2c4393d2 [eslint config] [base] v7.2.0 2016-09-23 16:00:11 -07:00
Jordan Harband
e8b51b2785 [eslint config] [*] [new] set ecmaVersion to 2017; enable object rest/spread; update babel-preset-airbnb 2016-09-21 17:17:27 -07:00
Jordan Harband
e5f4eb57b4 [eslint config] [*] [deps] update eslint-plugin-import, eslint to 3.6 2016-09-23 15:29:36 -07:00
Jordan Harband
4c598664fb [eslint config] [deps] update eslint-plugin-react 2016-09-20 00:13:37 -07:00
Jordan Harband
386a7b1d15 [eslint config] [*] [deps] update eslint-find-rules, safe-publish-latest 2016-09-20 00:03:30 -07:00
Joe Lencioni
53f67f8a47 Merge pull request #1083 from airbnb/react-props
Add rule to avoid misusing DOM component prop names
2016-09-19 11:52:12 -07:00
Joe Lencioni
a599bca474 Add rule to avoid misusing DOM component prop names
People expect props like `style` and `className` to mean one specific
thing. Varying this API for a subset of your app makes the code less
readable and less maintainable, and may cause bugs.
2016-09-19 11:42:12 -07:00
Jordan Harband
a86d546c61 [Docs] remove yet another wrapped-string "good" example 2016-09-16 16:12:06 -07:00
Kazuki Yamada
11b9adff01 Fix japanese translation link 2016-09-16 02:39:35 +09:00
Jordan Harband
a2a35a8dba [eslint config] [deps] update eslint-plugin-jsx-a11y, eslint-plugin-react 2016-09-14 12:55:24 -07:00
Jordan Harband
286b01c675 [eslint config] [*] [deps] update eslint-plugin-import 2016-09-14 12:54:45 -07:00
Harrison Shoff
bd5505b727 [commas] fix traling comma link 2016-09-14 09:42:44 -07:00
Jordan Harband
e9141f4630 [eslint config] [base] [patch] fix category of no-restricted-properties
Per https://github.com/eslint/eslint/issues/7112 / https://github.com/eslint/eslint/issues/7118
2016-09-12 11:02:12 -07:00
Guillaume Verbal
6cdda0737e [guide] Fix typo from #1058 2016-09-12 19:08:10 +08:00
Alexey Raspopov
2a28b9c82f move #variables--unary-increment-decrement to correct section 2016-09-12 10:06:15 +03:00
Guillaume Verbal
7da28d43ad [Docs] update 8.3 to fix conflict with 6.2 (fixes #1058) 2016-09-12 12:18:59 +08:00
Jordan Harband
e59376f625 [eslint config] v11.1.0 2016-09-11 15:51:58 -07:00
Jordan Harband
3fc37b3a26 [eslint config] [deps] update eslint-config-airbnb-base, eslint 2016-09-11 15:05:43 -07:00
Jordan Harband
715dea6598 [eslint config] [base] v7.1.0 2016-09-11 14:06:19 -07:00
Jordan Harband
6a72781121 [eslint config] [base] [minor] enable arrow-parens rule
This will cause new failures for some, but only for those not following our style guide already - hence, it’s not semver-major.
2016-09-11 13:20:17 -07:00
Jordan Harband
dbdd56ccb5 [eslint config] [base] v7.0.1 2016-09-10 14:35:57 -07:00
Jordan Harband
38f679e9f9 [eslint config] [base] [patch] loosen max-len by ignoring strings
Per https://github.com/eslint/eslint/pull/7049 / https://github.com/eslint/eslint/issues/5805
2016-09-10 14:29:35 -07:00
Jordan Harband
7412641af9 [eslint config] [base] [deps] update to eslint v3.5.0. 2016-09-10 14:28:26 -07:00
Joe Lencioni
ff69c8cb35 Prefer https over http
I checked all of the links in the JS style guide document and converted
as many as I could to use https.
2016-09-08 08:39:18 -07:00
Jordan Eldredge
7d46d3c59f Document react/require-render-return as a fully fledged rule
Now that the pull request has been merged, we can reference the actual rule.
2016-09-08 09:56:57 -07:00
Joe Lencioni
25123199dc Add JavaScript Air to list of Podcasts
It probably wouldn't be a bad idea for us to make a full pass on
updating the resources section, but I noticed the podcasts portion was
missing JS Air.
2016-09-08 08:29:10 -07:00
Joe Lencioni
68b7aeb6dd Add rule about TC39 proposals that haven't reached stage 3
There has been some confusion around which language features should be
used and which should not be used yet. We have a pretty clear-cut rule
at Airbnb about this, which is do not use any TC39 proposals that have
not reached stage 3.

I considered putting this at the very top of the document, but I spotted
this section that seemed to fit.

Addresses #1057
2016-09-08 08:19:27 -07:00
Joe Lencioni
e6782493f3 Update ECMAScript 6 heading to match TOC
I plan to add some information to this section that applies to ES6 and
everything following ES6. Since we already list this as ES6+ in the
table of contents, I figured it would be a good idea to make this match.

I preserved the anchor to avoid breaking links for folks.
2016-09-08 08:11:32 -07:00
Jordan Harband
f769e35018 [eslint config] v11.0.0 2016-09-08 00:19:10 -07:00
Jordan Harband
ccd18f8b40 [guide] Update declarations section to prefer expressions.
Fixes #1008.
2016-09-06 23:08:36 -07:00
Jordan Harband
7f12b9f043 [eslint config] [breaking] enable react rules:
- `react/no-danger-with-children`
 - `react/no-unused-prop-types`
 - `react/style-prop-object`
 - `react/forbid-prop-types`
 - `react/jsx-no-duplicate-props`

Also sets `react/no-danger` to “warn”.
2016-09-06 22:53:01 -07:00
Jordan Harband
4ce30fc891 [eslint config] [breaking] enable jsx-a11y rules:
- `jsx-a11y/anchor-has-content`
 - `jsx-a11y/tabindex-no-positive`
 - `jsx-a11y/no-static-element-interactions`
2016-09-06 22:46:52 -07:00
Jordan Harband
e037760bad [eslint config] [deps] update eslint-config-airbnb-base, eslint, eslint-find-rules, eslint-plugin-import, eslint-plugin-jsx-a11y, eslint-plugin-react 2016-09-06 17:10:48 -07:00
cshg
9abe878941 Fix header link to Classes & Constructors from ECMAScript 6+ Styles 2016-09-07 11:30:58 +02:00
Jordan Harband
49045060e0 [eslint config] [base] v7.0.0 2016-09-06 12:21:22 -07:00
scott stern
55d044c7c1 [eslint config] [base] [breaking] Add no-plusplus in style.js and added explanation in README. 2016-09-06 11:59:01 -07:00
Jordan Harband
bc3b15d4d7 [eslint config] [*] [docs] use “#” in example command rather than version numbers.
Closes #984.
2016-09-06 11:40:42 -07:00
Jordan Harband
e52f41c9cc [eslint config] [base] v6.0.0 2016-09-06 10:56:02 -07:00
Jordan Harband
9750f4261c [eslint config] [base] Update ecmaVersion to 2016. 2016-09-06 10:50:03 -07:00
Jordan Harband
d7d606ec0d [eslint config] [base] [breaking] valid-typeof: enable requireStringLiterals option 2016-09-06 10:48:21 -07:00
Jordan Harband
06ff74801b [eslint config] [base] [breaking] enable class-methods-use-this 2016-09-06 10:44:19 -07:00
Jordan Harband
2c5a775d7b [eslint config] [base] [breaking] enable symbol-description 2016-09-06 10:44:00 -07:00
Jordan Harband
3bf7035cec [eslint config] [base] [deps] update eslint, eslint-find-rules, eslint-plugin-import 2016-09-06 10:40:31 -07:00
Jordan Harband
a6d59f977e [eslint config] [base] [breaking] enable no-bitwise 2016-09-06 01:07:56 -07:00
Jordan Harband
aa4e9c466a [eslint config] [base] [breaking] enable no-tabs 2016-09-06 01:07:39 -07:00
Jordan Harband
27dcb99c6d [eslint config] [base] [breaking] enable func-call-spacing 2016-09-06 01:07:16 -07:00
Jordan Harband
086cc0035d [eslint config] [base] [breaking] enable no-template-curly-in-string
- Also, clean up rule documentation.
2016-09-06 00:36:04 -07:00
Jordan Harband
c829114a41 Merge pull request #1047 from airbnb/css-in-js
[guide] Add CSS-in-JavaScript section
2016-09-02 13:21:10 -07:00
Joe Lencioni
c6406330ea Add note about where where mystery objects come from
As @ljharb pointed out, we are using some functions like `css()` and
`withStyles()`, but make no mention of what they are or where they come
from. Since they come from react-with-styles, let's make this clear.
2016-09-02 07:57:33 -07:00
Joe Lencioni
c74caead2a Re-order breakpoints in CSS-in-JS document
This is more "mobile first".
2016-09-01 09:49:21 -07:00
Joe Lencioni
71a2b12262 Add CSS-in-JavaScript section
We have been writing CSS in JavaScript and have developed a set of best
practices around this type of thing. I thought it would be nice to
publish this document alongside our other JavaScript style guide
documents.
2016-09-01 09:49:21 -07:00
Jordan Harband
3a7210eac1 [guide] remove subtle endorsement of JSDoc-style commenting. 2016-08-31 21:54:51 -07:00
Jordan Harband
0e4517ea38 [eslint config] [patch] set ignoreCase to true in disabled rules.
When/if these rules are enabled, we will want to ignore case.

This also helps https://github.com/pinterest-web/eslint-config-pinterest/pull/46/files#r76165293
2016-08-29 00:11:52 -07:00
Thomas Marek
a43c16e330 Explain why not to prefix methods with underscores 2016-08-29 18:19:22 -04:00
Heejong Ahn
6944be009c Fix a typo in commas section
Example code block following blockquote(line 2223) was broken as a line break was missing. So I just added single blank line.
2016-08-28 23:09:11 +09:00
Harrison Shoff
1541503fd4 [7.1] add link to fn names discussion. fixes #794 2016-08-25 21:48:31 -07:00
Jordan Harband
48f477db2a [eslint config] [base] [patch] remove redundant DebuggerStatement from no-restricted-syntax
Fixes #1031.
2016-08-23 15:19:34 -07:00
Jordan Harband
21846f6da0 [guide] fix “long lines” example to not include strings.
Fixes #1027.
2016-08-23 15:07:42 -07:00
Jordan Harband
ca1124cd8d [eslint config] [base] v5.0.3 2016-08-21 23:25:19 -07:00
Yang Su
2e694723bf Changed ESLint rule configs to use 'off', 'warn', and 'error' instead of numbers for better readability 2016-08-20 15:36:57 -07:00
Jordan Harband
f1fedfa7ca ES2015 2016-08-18 23:08:45 -07:00
soul-wish
baf0fa5343 fix issue with eslint-config-airbnb README.md file formatting 2016-08-18 22:35:42 +03:00
Joe Lencioni
39d5559b9a Remove misleading reference to one-var eslint rule
This eslint rule does not enforce this style guide rule. I believe that
referencing it here will cause people to believe that this is enforced
via linting when it is not. As far as I know, there is no rule that
currently enforces this, but it would be nice to add one.
2016-08-18 10:35:23 -07:00
Olivier G
41623039e8 Typo : text link to 13.5 was not working (#1020) 2016-08-18 08:33:23 -07:00
Jordan Harband
3ad33681a7 [eslint config] [*] [deps] update eslint, eslint-plugin-react 2016-08-18 00:50:37 -07:00
Aniruddh Agarwal
b126016410 Add section on variable assignment chaining 2016-08-18 13:48:58 +08:00
Gerardo Renovales
e92eaef4e2 Update README.md
Add M2GEN to the list
2016-08-17 19:46:55 -04:00
Jordan Harband
db2e7bdf63 [eslint config] [base] [fix] correct import/extensions list.
From b45fdcd60f / fixes #1013.
2016-08-15 23:17:04 -07:00
Jordan Harband
424d74ec8d [eslint config] [deps] update eslint-plugin-react 2016-08-15 00:21:39 -07:00
Jordan Harband
3fb9f2ec69 [eslint config] v10.0.1 2016-08-12 15:52:10 -07:00
Jordan Harband
7d9af14ce4 [eslint config] [deps] update eslint, eslint-plugin-jsx-a11y, eslint-plugin-import, eslint-config-airbnb-base
- add temp disabled `jsx-a11y/anchor-has-content` rule
2016-08-12 15:49:45 -07:00
Jordan Harband
be6e13f7b9 [eslint config] [base] v5.0.2 2016-08-12 15:38:44 -07:00
Jordan Harband
fb0f03f676 [eslint config] [base] [deps] update eslint, eslint-plugin-import
- add temp disabled `func-call-spacing` rule
 - add temp disabled `no-template-curly-in-string` rule
 - enable `no-global-assign` and deprecate `no-native-reassign`
 - enable `no-unsafe-negation` and deprecate `no-negated-in-lhs`
 - add disabled `sort-keys` rule
2016-08-12 15:36:56 -07:00
Jordan Harband
0b8e466397 [eslint config] [*] [deps] update eslint, eslint-find-rules 2016-08-09 09:08:49 -07:00
Mitsuru Ogawa
d20f33f660 Add link for Japanese translation 2016-08-09 19:06:43 +09:00
Maxim
646fa70f59 Update README.md 2016-08-08 11:14:05 +03:00
felipethome
31265099af [guide] Simplify the examples of 'apply vs spread' topic 2016-08-05 18:38:35 -03:00
felipethome
c7d34b526a [guide] Add a topic about spread operator vs apply 2016-08-05 11:52:41 -03:00
felipethome
030598db09 [guide] Add ESlint rules to 'always use const' and 'decriptive variable names' topics 2016-08-04 14:13:12 -03:00
Joe Lencioni
dc7e7e77f2 Reverse rule on string concatenation for long lines (#995)
Broken and concatenated long strings are painful to work with and
produce less readable and searchable code. I think we should reverse
this rule.

Unfortunately, the max-len rule currently does not allow for this, but
there is currently a proposal to add an option to ESLint's max-len rule
that would allow for strings to be ignored.

  https://github.com/eslint/eslint/issues/5805

There have also been discussions around performance of string
concatenation (https://github.com/airbnb/javascript/issues/40), but I
don't think that is very relevant here so I removed the links to them.
2016-08-04 09:53:09 -07:00
Joe Lencioni
6d2fc89bd1 Add template literal "bad" example to single quotes guideline
There has been some confusion around whether we should use single quotes
or template literals. To help avoid this confusion, I am adding a "bad"
example to the single quotes guideline. This rule is already enforced by
the quotes linter rule.

Generally, we want code to clearly express developer intention. Using
template literals communicates that you intend to use some of the
features that template literals offer (e.g. interpolation).

Fixes #992
2016-08-04 09:38:12 -07:00
Joe Lencioni
bfc842e3ad Remove rules about reserved words
In 53b4173b we removed the ES5 guide which contains a lot of guidelines
that are no longer very relevant for us. Similarly, some folks have
raised the relevance of these rules about reserved words, given that we
are now living in an age where ES3 support has mostly waned and
transpilers such as Babel are widely adopted and pave over these issues.
This seems like a good opportunity to simplify.

Fixes #61
2016-08-03 14:41:16 -07:00
felipethome
f0b31960d3 [guide] Add eslint rules to function declaration and function constructor topics 2016-08-03 16:20:22 -03:00
felipethome
f94f6e21c6 [guide] Add eslint rule to spacing in a function signature topic
[guide] Add eslint rules to spacing in a function signature topic
2016-08-02 20:49:54 -03:00
Jordan Harband
6454839e76 [guide] Use var in reserved word examples, since they refer to untranspiled code. 2016-08-01 23:56:37 -07:00
Joe Lencioni
52a2da4182 Add curlies around ref function body
The example we have here uses an implicit return, which is forbidden
when assigning. This triggers the no-return-assign rule.

Fixes #980
2016-08-02 09:09:12 -07:00
Jordan Harband
9ffadff1fd [eslint config] v10.0.0 2016-08-01 13:53:30 -07:00
Jordan Harband
a1edac348a [eslint config] [*] add safe-publish-latest to prepublish 2016-08-01 14:05:32 -07:00
Jordan Harband
53b4173b04 [guide] [es5] Remove ES5 guide and mark it deprecated.
Fixes #941.
2016-07-06 18:13:13 -07:00
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
Estelle
5fd7c6f08c added naming convention of UPPERCASE names 2015-03-23 18:48:19 -07:00
63 changed files with 6526 additions and 3102 deletions

14
.editorconfig Normal file
View File

@@ -0,0 +1,14 @@
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
# editorconfig-tools is unable to ignore longs strings or urls
max_line_length = off
[CHANGELOG.md]
indent_size = false

26
.github/workflows/node-pretest.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
pretest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- '..'
- eslint-config-airbnb
- eslint-config-airbnb-base
defaults:
run:
working-directory: "packages/${{ matrix.package }}"
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install lts/* && npm install'
with:
node-version: 'lts/*'
- run: npm run pretest

163
.github/workflows/node.yml vendored Normal file
View File

@@ -0,0 +1,163 @@
name: 'Tests: node.js'
on: [pull_request, push]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
versionsAsRoot: true
type: 'majors'
preset: '^12 || ^14 || ^16 || >= 17'
base:
needs: [matrix]
name: 'base config'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 8
- 7
package:
- eslint-config-airbnb-base
exclude:
- node-version: 10
eslint: 8
package: eslint-config-airbnb-base
defaults:
run:
working-directory: "packages/${{ matrix.package }}"
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
before_install: cd "packages/${{ matrix.package }}"
node-version: ${{ matrix.node-version }}
after_install: |
npm install --no-save "eslint@${{ matrix.eslint }}"
- run: node -pe "require('eslint/package.json').version"
name: 'eslint version'
- run: npm run travis
- uses: codecov/codecov-action@v2
react:
needs: [matrix]
name: 'react config'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 8
- 7
package:
- eslint-config-airbnb
react-hooks:
- 4
defaults:
run:
working-directory: "packages/${{ matrix.package }}"
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
before_install: cd "packages/${{ matrix.package }}"
node-version: ${{ matrix.node-version }}
after_install: |
npm install --no-save "eslint@${{ matrix.eslint }}"
- run: node -pe "require('eslint/package.json').version"
name: 'eslint version'
- run: npm install --no-save "eslint-plugin-react-hooks@${{ matrix.react-hooks }}"
if: ${{ matrix.react-hooks > 0}}
- run: npm run travis
- uses: codecov/codecov-action@v2
prepublish-base:
name: 'prepublish tests (base config)'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
eslint:
- 8
- 7
package:
- eslint-config-airbnb-base
defaults:
run:
working-directory: "packages/${{ matrix.package }}"
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install lts/* && npm install'
with:
before_install: cd "packages/${{ matrix.package }}"
node-version: lts/*
after_install: |
npm install --no-save "eslint@${{ matrix.eslint }}"
- run: node -pe "require('eslint/package.json').version"
name: 'eslint version'
- run: npm run pretravis
- run: npm run prepublishOnly
- run: npm run posttravis
prepublish-react:
name: 'prepublish tests (react config)'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
eslint:
- 8
- 7
package:
- eslint-config-airbnb
react-hooks:
- 4
defaults:
run:
working-directory: "packages/${{ matrix.package }}"
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install lts/* && npm install'
with:
before_install: cd "packages/${{ matrix.package }}"
node-version: lts/*
after_install: |
npm install --no-save "eslint@${{ matrix.eslint }}"
- run: npm install --no-save "eslint-plugin-react-hooks@${{ matrix.react-hooks }}"
if: ${{ matrix.react-hooks > 0}}
- run: node -pe "require('eslint/package.json').version"
name: 'eslint version'
- run: npm run pretravis
- run: npm run prepublishOnly
- run: npm run posttravis
node:
name: 'node 10+'
needs: [base, prepublish-base, react, prepublish-react]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'

15
.github/workflows/rebase.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,12 @@
name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main

6
.gitignore vendored
View File

@@ -1 +1,7 @@
# gitignore
node_modules
# Only apps should have lockfiles
yarn.lock
package-lock.json

1
.npmrc Normal file
View File

@@ -0,0 +1 @@
package-lock=false

View File

@@ -1,20 +0,0 @@
language: node_js
node_js:
- "6"
- "5"
- "4"
- "iojs"
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 test'
sudo: false
matrix:
fast_finish: true
allow_failures:
- node_js: "iojs"

21
LICENSE.md Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2012 Airbnb
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2042
README.md

File diff suppressed because it is too large Load Diff

432
css-in-javascript/README.md Normal file
View File

@@ -0,0 +1,432 @@
# Airbnb CSS-in-JavaScript Style Guide
*A mostly reasonable approach to CSS-in-JavaScript*
## Table of Contents
1. [Naming](#naming)
1. [Ordering](#ordering)
1. [Nesting](#nesting)
1. [Inline](#inline)
1. [Themes](#themes)
## Naming
- Use camelCase for object keys (i.e. "selectors").
> Why? We access these keys as properties on the `styles` object in the component, so it is most convenient to use camelCase.
```js
// bad
{
'bermuda-triangle': {
display: 'none',
},
}
// good
{
bermudaTriangle: {
display: 'none',
},
}
```
- Use an underscore for modifiers to other styles.
> Why? Similar to BEM, this naming convention makes it clear that the styles are intended to modify the element preceded by the underscore. Underscores do not need to be quoted, so they are preferred over other characters, such as dashes.
```js
// bad
{
bruceBanner: {
color: 'pink',
transition: 'color 10s',
},
bruceBannerTheHulk: {
color: 'green',
},
}
// good
{
bruceBanner: {
color: 'pink',
transition: 'color 10s',
},
bruceBanner_theHulk: {
color: 'green',
},
}
```
- Use `selectorName_fallback` for sets of fallback styles.
> Why? Similar to modifiers, keeping the naming consistent helps reveal the relationship of these styles to the styles that override them in more adequate browsers.
```js
// bad
{
muscles: {
display: 'flex',
},
muscles_sadBears: {
width: '100%',
},
}
// good
{
muscles: {
display: 'flex',
},
muscles_fallback: {
width: '100%',
},
}
```
- Use a separate selector for sets of fallback styles.
> Why? Keeping fallback styles contained in a separate object clarifies their purpose, which improves readability.
```js
// bad
{
muscles: {
display: 'flex',
},
left: {
flexGrow: 1,
display: 'inline-block',
},
right: {
display: 'inline-block',
},
}
// good
{
muscles: {
display: 'flex',
},
left: {
flexGrow: 1,
},
left_fallback: {
display: 'inline-block',
},
right_fallback: {
display: 'inline-block',
},
}
```
- Use device-agnostic names (e.g. "small", "medium", and "large") to name media query breakpoints.
> Why? Commonly used names like "phone", "tablet", and "desktop" do not match the characteristics of the devices in the real world. Using these names sets the wrong expectations.
```js
// bad
const breakpoints = {
mobile: '@media (max-width: 639px)',
tablet: '@media (max-width: 1047px)',
desktop: '@media (min-width: 1048px)',
};
// good
const breakpoints = {
small: '@media (max-width: 639px)',
medium: '@media (max-width: 1047px)',
large: '@media (min-width: 1048px)',
};
```
## Ordering
- Define styles after the component.
> Why? We use a higher-order component to theme our styles, which is naturally used after the component definition. Passing the styles object directly to this function reduces indirection.
```jsx
// bad
const styles = {
container: {
display: 'inline-block',
},
};
function MyComponent({ styles }) {
return (
<div {...css(styles.container)}>
Never doubt that a small group of thoughtful, committed citizens can
change the world. Indeed, its the only thing that ever has.
</div>
);
}
export default withStyles(() => styles)(MyComponent);
// good
function MyComponent({ styles }) {
return (
<div {...css(styles.container)}>
Never doubt that a small group of thoughtful, committed citizens can
change the world. Indeed, its the only thing that ever has.
</div>
);
}
export default withStyles(() => ({
container: {
display: 'inline-block',
},
}))(MyComponent);
```
## Nesting
- Leave a blank line between adjacent blocks at the same indentation level.
> Why? The whitespace improves readability and reduces the likelihood of merge conflicts.
```js
// bad
{
bigBang: {
display: 'inline-block',
'::before': {
content: "''",
},
},
universe: {
border: 'none',
},
}
// good
{
bigBang: {
display: 'inline-block',
'::before': {
content: "''",
},
},
universe: {
border: 'none',
},
}
```
## Inline
- Use inline styles for styles that have a high cardinality (e.g. uses the value of a prop) and not for styles that have a low cardinality.
> Why? Generating themed stylesheets can be expensive, so they are best for discrete sets of styles.
```jsx
// bad
export default function MyComponent({ spacing }) {
return (
<div style={{ display: 'table', margin: spacing }} />
);
}
// good
function MyComponent({ styles, spacing }) {
return (
<div {...css(styles.periodic, { margin: spacing })} />
);
}
export default withStyles(() => ({
periodic: {
display: 'table',
},
}))(MyComponent);
```
## Themes
- Use an abstraction layer such as [react-with-styles](https://github.com/airbnb/react-with-styles) that enables theming. *react-with-styles gives us things like `withStyles()`, `ThemedStyleSheet`, and `css()` which are used in some of the examples in this document.*
> Why? It is useful to have a set of shared variables for styling your components. Using an abstraction layer makes this more convenient. Additionally, this can help prevent your components from being tightly coupled to any particular underlying implementation, which gives you more freedom.
- Define colors only in themes.
```js
// bad
export default withStyles(() => ({
chuckNorris: {
color: '#bada55',
},
}))(MyComponent);
// good
export default withStyles(({ color }) => ({
chuckNorris: {
color: color.badass,
},
}))(MyComponent);
```
- Define fonts only in themes.
```js
// bad
export default withStyles(() => ({
towerOfPisa: {
fontStyle: 'italic',
},
}))(MyComponent);
// good
export default withStyles(({ font }) => ({
towerOfPisa: {
fontStyle: font.italic,
},
}))(MyComponent);
```
- Define fonts as sets of related styles.
```js
// bad
export default withStyles(() => ({
towerOfPisa: {
fontFamily: 'Italiana, "Times New Roman", serif',
fontSize: '2em',
fontStyle: 'italic',
lineHeight: 1.5,
},
}))(MyComponent);
// good
export default withStyles(({ font }) => ({
towerOfPisa: {
...font.italian,
},
}))(MyComponent);
```
- Define base grid units in theme (either as a value or a function that takes a multiplier).
```js
// bad
export default withStyles(() => ({
rip: {
bottom: '-6912px', // 6 feet
},
}))(MyComponent);
// good
export default withStyles(({ units }) => ({
rip: {
bottom: units(864), // 6 feet, assuming our unit is 8px
},
}))(MyComponent);
// good
export default withStyles(({ unit }) => ({
rip: {
bottom: 864 * unit, // 6 feet, assuming our unit is 8px
},
}))(MyComponent);
```
- Define media queries only in themes.
```js
// bad
export default withStyles(() => ({
container: {
width: '100%',
'@media (max-width: 1047px)': {
width: '50%',
},
},
}))(MyComponent);
// good
export default withStyles(({ breakpoint }) => ({
container: {
width: '100%',
[breakpoint.medium]: {
width: '50%',
},
},
}))(MyComponent);
```
- Define tricky fallback properties in themes.
> Why? Many CSS-in-JavaScript implementations merge style objects together which makes specifying fallbacks for the same property (e.g. `display`) a little tricky. To keep the approach unified, put these fallbacks in the theme.
```js
// bad
export default withStyles(() => ({
.muscles {
display: 'flex',
},
.muscles_fallback {
'display ': 'table',
},
}))(MyComponent);
// good
export default withStyles(({ fallbacks }) => ({
.muscles {
display: 'flex',
},
.muscles_fallback {
[fallbacks.display]: 'table',
},
}))(MyComponent);
// good
export default withStyles(({ fallback }) => ({
.muscles {
display: 'flex',
},
.muscles_fallback {
[fallback('display')]: 'table',
},
}))(MyComponent);
```
- Create as few custom themes as possible. Many applications may only have one theme.
- Namespace custom theme settings under a nested object with a unique and descriptive key.
```js
// bad
ThemedStyleSheet.registerTheme('mySection', {
mySectionPrimaryColor: 'green',
});
// good
ThemedStyleSheet.registerTheme('mySection', {
mySection: {
primaryColor: 'green',
},
});
```
---
CSS puns adapted from [Saijo George](https://saijogeorge.com/css-puns/).

File diff suppressed because it is too large Load Diff

155
linters/.markdownlint.json Normal file
View File

@@ -0,0 +1,155 @@
{
"comment": "Be explicit by listing every available rule. https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md",
"comment": "Note that there will be numeric gaps, not every MD number is implemented in markdownlint.",
"comment": "MD001: Header levels should only increment by one level at a time.",
"header-increment": true,
"comment": "MD002: First header should be a top level header.",
"first-header-h1": true,
"comment": "MD003: Header style: start with hashes.",
"header-style": {
"style": "atx"
},
"comment": "MD004: Unordered list style",
"ul-style": {
"style": "dash"
},
"comment": "MD005: Consistent indentation for list items at the same level.",
"list-indent": true,
"comment": "MD006: Consider starting bulleted lists at the beginning of the line.",
"ul-start-left": false,
"comment": "MD007: Unordered list indentation: 2 spaces.",
"ul-indent": {
"indent": 2,
"start_indented": true
},
"comment": "MD009: Disallow trailing spaces!",
"no-trailing-spaces": {
"br_spaces": 0,
"comment": "Empty lines inside list items should not be indented.",
"list_item_empty_lines": false
},
"comment": "MD010: No hard tabs, not even in code blocks.",
"no-hard-tabs": {
"code_blocks": true
},
"comment": "MD011: Prevent reversed link syntax",
"no-reversed-links": true,
"comment": "MD012: Disallow multiple consecutive blank lines.",
"no-multiple-blanks": {
"maximum": 1
},
"comment": "MD013: Line length",
"line-length": false,
"comment": "MD014: Disallow use of dollar signs($) before commands without showing output.",
"commands-show-output": true,
"comment": "MD018: Disallow space after hash on atx style header.",
"no-missing-space-atx": true,
"comment": "MD019: Disallow multiple spaces after hash on atx style header.",
"no-multiple-space-atx": true,
"comment": "MD020: No space should be inside hashes on closed atx style header.",
"no-missing-space-closed-atx": true,
"comment": "MD021: Disallow multiple spaces inside hashes on closed atx style header.",
"no-multiple-space-closed-atx": true,
"comment": "MD022: Headers should be surrounded by blank lines.",
"comment": "Some headers have preceding HTML anchors. Unfortunate that we have to disable this, as it otherwise catches a real problem that trips up some Markdown renderers",
"blanks-around-headers": false,
"comment": "MD023: Headers must start at the beginning of the line.",
"header-start-left": true,
"comment": "MD024: Disallow multiple headers with the same content.",
"no-duplicate-header": true,
"comment": "MD025: Disallow multiple top level headers in the same document.",
"comment": "Gotta have a matching closing brace at the end.",
"single-h1": false,
"comment": "MD026: Disallow trailing punctuation in header.",
"comment": "You must have a semicolon after the ending closing brace.",
"no-trailing-punctuation": {
"punctuation" : ".,:!?"
},
"comment": "MD027: Dissalow multiple spaces after blockquote symbol",
"no-multiple-space-blockquote": true,
"comment": "MD028: Blank line inside blockquote",
"comment": "Some 'Why?' and 'Why not?' blocks are separated by a blank line",
"no-blanks-blockquote": false,
"comment": "MD029: Ordered list item prefix",
"ol-prefix": {
"style": "one"
},
"comment": "MD030: Spaces after list markers",
"list-marker-space": {
"ul_single": 1,
"ol_single": 1,
"ul_multi": 1,
"ol_multi": 1
},
"comment": "MD031: Fenced code blocks should be surrounded by blank lines",
"blanks-around-fences": true,
"comment": "MD032: Lists should be surrounded by blank lines",
"comment": "Some lists have preceding HTML anchors. Unfortunate that we have to disable this, as it otherwise catches a real problem that trips up some Markdown renderers",
"blanks-around-lists": false,
"comment": "MD033: Disallow inline HTML",
"comment": "HTML is needed for explicit anchors",
"no-inline-html": false,
"comment": "MD034: No bare URLs should be used",
"no-bare-urls": true,
"comment": "MD035: Horizontal rule style",
"hr-style": {
"style": "consistent"
},
"comment": "MD036: Do not use emphasis instead of a header.",
"no-emphasis-as-header": false,
"comment": "MD037: Disallow spaces inside emphasis markers.",
"no-space-in-emphasis": true,
"comment": "MD038: Disallow spaces inside code span elements.",
"no-space-in-code": true,
"comment": "MD039: Disallow spaces inside link text.",
"no-space-in-links": true,
"comment": "MD040: Fenced code blocks should have a language specified.",
"fenced-code-language": true,
"comment": "MD041: First line in file should be a top level header.",
"first-line-h1": true,
"comment": "MD042: No empty links",
"no-empty-links": true,
"comment": "MD043: Required header structure.",
"required-headers": false,
"comment": "MD044: Proper names should have the correct capitalization.",
"proper-names": false
}

View File

@@ -9,7 +9,7 @@
*
* @version 0.3.0
* @see https://github.com/SublimeLinter/SublimeLinter
* @see http://www.jshint.com/docs/
* @see https://www.jshint.com/docs/
*/
{
"jshint_options":

View File

@@ -4,11 +4,18 @@
"description": "A mostly reasonable approach to JavaScript.",
"scripts": {
"preinstall": "npm run install:config && npm run install:config:base",
"install:config": "cd packages/eslint-config-airbnb && npm install",
"install:config:base": "cd packages/eslint-config-airbnb-base && npm install",
"postinstall": "rm -rf node_modules/markdownlint-cli/node_modules/markdownlint",
"install:config": "cd packages/eslint-config-airbnb && npm prune && npm install",
"install:config:base": "cd packages/eslint-config-airbnb-base && npm prune && npm install",
"lint": "markdownlint --config linters/.markdownlint.json README.md */README.md",
"pretest": "npm run --silent lint",
"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"
"test:config:base": "cd packages/eslint-config-airbnb-base; npm test",
"pretravis": "npm run --silent lint",
"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",
@@ -20,6 +27,9 @@
"airbnb",
"es6",
"es2015",
"es2016",
"es2017",
"es2018",
"react",
"jsx"
],
@@ -28,5 +38,9 @@
"bugs": {
"url": "https://github.com/airbnb/javascript/issues"
},
"homepage": "https://github.com/airbnb/javascript"
"homepage": "https://github.com/airbnb/javascript",
"devDependencies": {
"markdownlint": "^0.28.2",
"markdownlint-cli": "^0.34.0"
}
}

View File

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

View File

@@ -0,0 +1 @@
../../.editorconfig

View File

@@ -3,6 +3,8 @@
"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
}
"comma-dangle": 0,
"max-len": 0,
},
}

View File

@@ -0,0 +1 @@
../../.npmrc

View File

@@ -1,3 +1,338 @@
15.0.0 / 2021-11-08
==================
- [breaking] drop eslint < 7, add eslint 8 (#2495)
- [breaking] add `exports`
- [patch] Improve `function-paren-newline` with `multiline-arguments` option (#2471)
- [patch] update default value for complexity (#2420)
- [patch] add disabled `no-unsafe-optional-chaining` rule
- [patch] arthmetic -> arithmetic (#2341)
- [patch] fix spelling of "than" (#2333)
- [patch] add `no-nonoctal-decimal-escape` rule
- [patch] `import/no-extraneous-dependencies`: Add .eslintrc.js to devDeps (#2329)
- [guide] Spread operator => Spread syntax (#2423)
- [guide] add references for eslint rules (#2419)
- [Docs] HTTP => HTTPS (#2489)
- [readme] some updates
- [meta] use `prepublishOnly` script for npm 7+
- [deps] update `eslint-plugin-import`, `eslint-plugin-react`, `object.entries`
- [dev deps] update `@babel/runtime`, `tape`
14.2.1 / 2020-11-06
==================
- [base] `no-restricted-globals`: add better messages (#2320)
- [base] add new core eslint rules, set to off
- [deps] update `confusing-browser-globals`, `object.assign`
- [deps] update `eslint-plugin-import`, use valid `import/no-cycle` `maxDepth` option (#2250, #2249)
- [dev deps] update `@babel/runtime`, `eslint-find-rules`, `eslint-plugin-import`
14.2.0 / 2020-06-10
==================
- [new] add `eslint` `v7`
- [minor] Disallow multiple empty lines (#2238)
- [minor] Fix typo in no-multiple-empty-lines rule (#2168)
- [patch] Include 'context' exception for `no-param-reassign` (#2230)
- [patch] Allow triple-slash (///) comments (#2197)
- [patch] Disable `prefer-object-spread` for `airbnb-base/legacy` (#2198)
- [deps] update `eslint-plugin-import`, `eslint-plugin-react`, `babel-preset-airbnb`, `eslint-find-rules`, `in-publish`, `tape`, `object.entries`
14.1.0 / 2020-03-12
==================
- [minor] add new disabled rules, update eslint
- [minor] enable `import/no-useless-path-segments` for commonjs (#2113)
- [fix] `whitespace`: only set erroring rules to "warn"
- Fix indentation with JSX Fragments (#2157)
- [patch] `import/no-extraneous-dependencies`: Support karma config files (#2121)
- [readme] normalize multiline word according to merriam-webster (#2138)
- [deps] update `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `object.entries`, `confusing-browser-globals`
- [dev deps] update `@babel/runtime`, `babel-preset-airbnb`, `safe-publish-latest`, `tape`
- [tests] re-enable eslint rule `prefer-destructuring` internally (#2110)
14.0.0 / 2019-08-09
==================
- [breaking] `no-self-assign`: enable `props` option
- [breaking] enable `no-useless-catch`
- [breaking] enable `max-classes-per-file`
- [breaking] enable `no-misleading-character-class`
- [breaking] enable `no-async-promise-executor`
- [breaking] enable `prefer-object-spread`
- [breaking] `func-name-matching`: enable `considerPropertyDescriptor` option
- [breaking] `padded-blocks`: enable `allowSingleLineBlocks` option (#1255)
- [breaking] `no-multiple-empty-lines`: Restrict empty lines at beginning of file (#2042)
- [breaking] Set 'strict' to 'never' (#1962)
- [breaking] legacy: Enable 'strict' (#1962)
- [breaking] Simplifies `no-mixed-operators` (#1864)
- [breaking] Require parens for arrow function args (#1863)
- [breaking] add eslint v6, drop eslint v4
- [patch] `camelcase`: enable ignoreDestructuring
- [patch] Add markers to spaced-comment block for Flow types (#1966)
- [patch] Do not prefer destructuring for object assignment expression (#1583)
- [deps] update `confusing-browser-globals`, `eslint-plugin-import`, `tape`, `babel-preset-airbnb`
- [dev deps] update babel-related deps to latest
- [dev deps] update `eslint-find-rules`, `eslint-plugin-import`
- [tests] only run tests in non-lint per-package travis job
- [tests] use `eclint` instead of `editorconfig-tools`
13.2.0 / 2019-07-01
==================
- [minor] Enforce dangling underscores in method names (#1907)
- [fix] disable `no-var` in legacy entry point
- [patch] Ignore property modifications of `staticContext` params (#2029)
- [patch] `no-extraneous-dependencies`: Add jest.setup.js to devDeps (#1998)
- [meta] add disabled `prefer-named-capture-group` rule
- [meta] add disabled `no-useless-catch` config
- [deps] Switch to confusing-browser-globals (#1961)
- [deps] update `object.entries`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `tape`
- [docs] correct JavaScript capitalization (#2046)
- [readme] Improve eslint config setup instructions for yarn (#2001)
- [docs] fix docs for whitespace config (#1914, #1871)
13.1.0 / 2018-08-13
==================
- [new] add eslint v5 support (#1834)
- [deps] update `eslint-plugin-import`, `eslint`, `babel-preset-airbnb`, `safe-publish-latest`, `eslint-find-rules`
- [docs] fix typo in readme (#1855)
- [new] update base ecmaVersion to 2018; remove deprecated experimentalObjectRestSpread option
13.0.0 / 2018-06-21
==================
- [breaking] order of import statements is ignored for unassigned imports (#1782)
- [breaking] enable `import/no-cycle`: warn on cyclical dependencies (#1779)
- [breaking] Change import/no-self-import from "off" to "error" (#1770)
- [breaking] Update `object-curly-newline` to match eslint 4.18.0 (#1761)
- [breaking] enable `no-useless-path-segments` (#1743)
- [breaking] Prevent line breaks before and after `=` (#1710)
- [breaking] Add .mjs extension support (#1634)
- [breaking] enable `implicit-arrow-linebreak`
- [breaking] Enables `nonblock-statement-body-position` rule and adds link to guide (#1618)
- [breaking] `no-mixed-operators`: only warn on `**` and `%` mixed with arithmetic operators; removes violation against mixing common math operators. (#1611)
- [breaking] `import/named`: enable
- [breaking] `lines-between-class-members`: set to “always”
- [breaking] `no-else-return`: disallow else-if (#1595)
- [breaking] Enables eslint rule for operator-linebreak
- [new] Adds config entry point with only whitespace rules enabled (#1749, #1751)
- [minor] only allow one newline at the end (#1794)
- [patch] Adjust imports for vue-cli (#1809)
- [patch] Allow devDependencies for `foo_spec.js` naming style (#1732)
- [patch] `function-paren-newline`: change to "consistent"
- [patch] avoid `__mocks__` `no-extraneous-dependencies` check (#1772)
- [patch] Include 'accumulator' exception for `no-param-reassign` (#1768)
- [patch] Set import/extensions to ignorePackages (#1652)
- [patch] properly ignore indentation on jsx
- [patch] `array-callback-return`: enable `allowImplicit` option (#1668)
- [deps] update `eslint`, `eslint-plugin-import`
- [dev deps] update `babel-preset-airbnb`, `tape`, `eslint-find-rules`
- [meta] add ES2015-2018 in npm package keywords (#1587)
- [meta] Add licenses to sub packages (#1746)
- [docs] add `npx` shortcut (#1694)
- [docs] Use HTTPS for links to ESLint documentation (#1628)
- [tests] ensure all entry points parse
12.1.0 / 2017-10-16
==================
- [deps] update `eslint` to `v4.9`
12.0.2 / 2017-10-05
==================
- [deps] update `eslint`
12.0.1 / 2017-09-27
==================
- [fix] ensure all JSX elements are ignored by `indent` (#1569)
- [deps] update `eslint`
12.0.0 / 2017-09-02
==================
- [deps] [breaking] require `eslint` v4
- enable `function-paren-newline`, `for-direction`, `getter-return`, `no-compare-neg-zero`, `semi-style`, `object-curly-newline`, `no-buffer-constructor`, `no-restricted-globals`, `switch-colon-spacing`, `template-tag-spacing`, `prefer-promise-reject-errors`, `prefer-destructuring`
- improve `indent`, `no-multi-spaces`, `no-trailing-spaces`, `no-underscore-dangle`
- [breaking] move `comma-dangle` to Stylistic Issues (#1514)
- [breaking] Rules prohibiting global isNaN, isFinite (#1477)
- [patch] also disallow padding in classes and switches (#1403)
- [patch] support Protractor config files in import/no-extraneous-dependencies (#1543)
11.3.2 / 2017-08-22
==================
- [patch] Add jest.config.js to import/no-extraneous-dependencies devDeps (#1522)
- [patch] Improve Gruntfile glob pattern (#1503)
- [deps] update `eslint` v4, `tape`
- [docs] Specify yarn-specific install instructions (#1511)
11.3.1 / 2017-07-24
==================
- [fix] `legacy`: remove top-level `ecmaFeatures`
11.3.0 / 2017-07-23
==================
- [deps] allow eslint v3 or v4 (#1447)
- [deps] update `eslint-plugin-import`
- [minor] Balanced spacing for inline block comments (#1440)
- [minor] `no-return-assign`: strengthen linting against returning assignments
- [patch] Allow jsx extensions for test files (#1427)
- [patch] `no-restricted-globals`: add confusing globals; leave disabled for now (#1420)
- [patch] Support Protractor config files in import/no-extraneous-dependencies (#1456)
- [docs] Remove TODO in prefer-reflect as it's deprecated (#1452)
- [docs] add yarn instructions (#1463, #1464)
11.2.0 / 2017-05-14
==================
- [minor] Disallow unused global variables
11.1.3 / 2017-04-03
==================
- [patch] add error messages to `no-restricted-syntax` (#1353)
- [deps] update `eslint`
11.1.2 / 2017-03-25
==================
- [patch] `no-param-reassign`: add ignorePropertyModificationsFor (#1325)
- [deps] update `eslint`
11.1.1 / 2017-03-03
==================
- [deps] update `eslint`
- [patch] enable `ignoreRestSiblings` in `no-unused-vars`
11.1.0 / 2017-01-08
==================
- [minor] enable `no-multi-assign`
- [deps] update `eslint`, `babel-preset-airbnb`
- Update a deprecated option (`eqeqeq`) (#1244)
11.0.1 / 2017-01-08
==================
- [deps] update `eslint`
- [docs] add note about `install-peerdeps` (#1234)
- [docs] Updated instructions to support non-bash users (#1214)
11.0.0 / 2016-12-11
==================
- [breaking] enable `no-await-in-loop`
- [patch] disable `no-duplicate-imports` rule (#1188, #1195, #1054)
- [patch] `import/no-extraneous-dependencies`: add some comments to ignore patterns
- [patch] add `import/no-extraneous-dependencies` ignore patterns for test files (#1174)
- [patch] `import/no-extraneous-dependencies`: added ignore patterns for config files (#1168)
- [deps] update `eslint`, `eslint-plugin-import`, `tape`
10.0.1 / 2016-11-07
==================
- [fix] legacy config should not require `**`
10.0.0 / 2016-11-06
==================
- [breaking] prefer `**` over `Math.pow`
- [breaking] `comma-dangle`: require trailing commas for functions
- [breaking] enable `no-useless-return`
- [breaking] tighten up `indent`
- [breaking] tighten up `spaced-comment`
- [breaking] enable `import/no-named-default`
- [patch] loosen `max-len` with `ignoreRegExpLiterals` option
- [patch] loosen `no-extraneous-dependencies` for test files (#959, #1089)
- [deps] update `eslint`, `eslint-plugin-import`
- [dev deps] update `eslint-find-rules`
- [Tests] on `node` `v7`
9.0.0 / 2016-10-16
==================
- [breaking] Add `ForOfStatement` to `no-restricted-syntax` (#1122, #1134)
- [breaking] enable `import/no-webpack-loader-syntax` (#1123)
- [breaking] [deps] update `eslint` to `v3.8.0` (#1132)
- [breaking] [deps] update `eslint-plugin-import` to v2 (#1101)
- [patch] `new-cap`: add immutable.js exceptions
- [docs] ensure latest version of config is installed
- [dev deps] update `babel-preset-airbnb`, `eslint`, `eslint-find-rules`, `tape`, `safe-publish-latest`
8.0.0 / 2016-09-24
==================
- [breaking] enable rules: `no-restricted-properties`, `prefer-numeric-literals`, `lines-around-directive`, `import/extensions`, `import/no-absolute-path`, `import/no-dynamic-require`
7.2.0 / 2016-09-23
==================
- [new] set `ecmaVersion` to 2017; enable object rest/spread; update `babel-preset-airbnb`
- [patch] fix category of `no-restricted-properties`
- [deps] update `eslint`, `eslint-plugin-import`, `eslint-find-rules`, `safe-publish-latest`
7.1.0 / 2016-09-11
==================
- [minor] enable `arrow-parens` rule
7.0.1 / 2016-09-10
==================
- [patch] loosen `max-len` by ignoring strings
- [deps] update to `eslint` `v3.5.0`
7.0.0 / 2016-09-06
==================
- [breaking] Add no-plusplus in style.js and added explanation in README (#1012)
6.0.0 / 2016-09-06
==================
- [breaking] `valid-typeof`: enable `requireStringLiterals` option
- [breaking] enable `class-methods-use-this`
- [breaking] enable `symbol-description`
- [breaking] enable `no-bitwise`
- [breaking] enable `no-tabs`
- [breaking] enable `func-call-spacing`
- [breaking] enable `no-template-curly-in-string`
- [patch] remove redundant `DebuggerStatement` from `no-restricted-syntax` (#1031)
- [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-import`
- Update `ecmaVersion` to `2016`
5.0.3 / 2016-08-21
==================
- [fix] correct `import/extensions` list (#1013)
- [refactor] Changed ESLint rule configs to use 'off', 'warn', and 'error' instead of numbers for better readability (#946)
- [deps] update `eslint`, `eslint-plugin-react`
5.0.2 / 2016-08-12
==================
- [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-import`
- [tests] add `safe-publish-latest` to `prepublish`
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)

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2012 Airbnb
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,8 +1,12 @@
# eslint-config-airbnb-base
# eslint-config-airbnb-base <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](http://badge.fury.io/js/eslint-config-airbnb-base)
[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)][package-url]
This package provides Airbnb's base JS .eslintrc as an extensible shared config.
[![github actions][actions-image]][actions-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
This package provides Airbnb's base JS .eslintrc (without React plugins) as an extensible shared config.
## Usage
@@ -12,17 +16,83 @@ We export two ESLint configurations for your usage.
Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`.
1. `npm install --save-dev eslint-config-airbnb-base eslint-plugin-import eslint`
2. add `"extends": "airbnb-base"` to your .eslintrc
1. Install the correct versions of each package, which are listed by the command:
```sh
npm info "eslint-config-airbnb-base@latest" peerDependencies
```
If using **npm 5+**, use this shortcut
```sh
npx install-peerdeps --dev eslint-config-airbnb-base
```
If using **yarn**, you can also use the shortcut described above if you have npm 5+ installed on your machine, as the command will detect that you are using yarn and will act accordingly.
Otherwise, run `npm info "eslint-config-airbnb-base@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev <dependency>@<version>` for each listed peer dependency.
If using **npm < 5**, Linux/OSX users can run
```sh
(
export PKG=eslint-config-airbnb-base;
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)
```
Which produces and runs a command like:
```sh
npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.#
```
If using **npm < 5**, Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool.
```sh
npm install -g install-peerdeps
install-peerdeps --dev eslint-config-airbnb-base
```
The cli will produce and run a command like:
```sh
npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.#
```
2. Add `"extends": "airbnb-base"` to your .eslintrc.
### eslint-config-airbnb-base/legacy
Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
1. `npm install --save-dev eslint-config-airbnb-base eslint-plugin-import eslint`
2. add `"extends": "airbnb-base/legacy"` to your .eslintrc
1. Install the correct versions of each package, which are listed by the command:
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.
```sh
npm info "eslint-config-airbnb-base@latest" peerDependencies
```
Linux/OSX users can run
```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@^#.#.# eslint-plugin-import@^#.#.#
```
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](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information.
### eslint-config-airbnb-base/whitespace
This entry point only errors on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/whitespace.js).
## Improving this config
@@ -31,3 +101,12 @@ Consider adding test cases if you're making complicated rules changes, like anyt
You can run tests with `npm test`.
You can make sure this module lints with itself using `npm run lint`.
[package-url]: https://npmjs.org/package/eslint-config-airbnb-base
[npm-version-svg]: https://versionbadg.es/airbnb/javascript.svg
[license-image]: https://img.shields.io/npm/l/eslint-config-airbnb-base.svg
[license-url]: LICENSE.md
[downloads-image]: https://img.shields.io/npm/dm/eslint-config-airbnb-base.svg
[downloads-url]: https://npm-stat.com/charts.html?package=eslint-config-airbnb-base
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/airbnb/javascript
[actions-url]: https://github.com/airbnb/javascript/actions

View File

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

View File

@@ -2,7 +2,6 @@ module.exports = {
extends: [
'./rules/best-practices',
'./rules/errors',
'./rules/legacy',
'./rules/node',
'./rules/style',
'./rules/variables'
@@ -14,7 +13,22 @@ module.exports = {
mocha: false,
jasmine: false
},
ecmaFeatures: {},
globals: {},
rules: {}
rules: {
'comma-dangle': ['error', 'never'],
'prefer-numeric-literals': 'off',
'no-restricted-properties': ['error', {
object: 'arguments',
property: 'callee',
message: 'arguments.callee is deprecated',
}, {
property: '__defineGetter__',
message: 'Please use Object.defineProperty instead.',
}, {
property: '__defineSetter__',
message: 'Please use Object.defineProperty instead.',
}],
'no-var': 'off',
'prefer-object-spread': 'off',
strict: ['error', 'safe'],
}
};

View File

@@ -1,13 +1,34 @@
{
"name": "eslint-config-airbnb-base",
"version": "3.0.1",
"version": "15.0.0",
"description": "Airbnb's base JS ESLint config, following our styleguide",
"main": "index.js",
"exports": {
".": "./index.js",
"./legacy": "./legacy.js",
"./whitespace": "./whitespace.js",
"./rules/best-practices": "./rules/best-practices.js",
"./rules/es6": "./rules/es6.js",
"./rules/node": "./rules/node.js",
"./rules/style": "./rules/style.js",
"./rules/errors": "./rules/errors.js",
"./rules/imports": "./rules/imports.js",
"./rules/strict": "./rules/strict.js",
"./rules/variables": "./rules/variables.js",
"./package.json": "./package.json"
},
"scripts": {
"lint": "eslint .",
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
"lint": "eslint --report-unused-disable-directives .",
"pretests-only": "node ./test/requires",
"tests-only": "babel-tape-runner ./test/test-*.js",
"pretest": "eslint-find-rules --unused",
"test": "npm run --silent lint && npm run --silent tests-only"
"prepublishOnly": "eslint-find-rules --unused && npm test && safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"pretravis": ":",
"travis": "npm run --silent tests-only",
"posttravis": ":"
},
"repository": {
"type": "git",
@@ -19,7 +40,11 @@
"config",
"airbnb",
"javascript",
"styleguide"
"styleguide",
"es2015",
"es2016",
"es2017",
"es2018"
],
"author": "Jake Teton-Landis (https://twitter.com/@jitl)",
"contributors": [
@@ -43,14 +68,26 @@
},
"homepage": "https://github.com/airbnb/javascript",
"devDependencies": {
"babel-tape-runner": "^1.3.1",
"eslint": "^2.9.0",
"eslint-find-rules": "^1.9.2",
"eslint-plugin-import": "^1.7.0",
"tape": "^4.5.1"
"@babel/runtime": "^7.21.5",
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-find-rules": "^4.1.0",
"eslint-plugin-import": "^2.27.5",
"in-publish": "^2.0.1",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.3"
},
"peerDependencies": {
"eslint": "^2.9.0",
"eslint-plugin-import": "^1.7.0"
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.27.5"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
},
"dependencies": {
"confusing-browser-globals": "^1.0.11",
"object.entries": "^1.1.6"
}
}

View File

@@ -1,5 +0,0 @@
{
"rules": {
"quote-props": 0
}
}

View File

@@ -1,171 +1,419 @@
module.exports = {
'rules': {
rules: {
// enforces getter/setter pairs in objects
'accessor-pairs': 0,
// https://eslint.org/docs/rules/accessor-pairs
'accessor-pairs': 'off',
// enforces return statements in callbacks of array's methods
// http://eslint.org/docs/rules/array-callback-return
'array-callback-return': 2,
// https://eslint.org/docs/rules/array-callback-return
'array-callback-return': ['error', { allowImplicit: true }],
// treat var statements as if they were block scoped
'block-scoped-var': 2,
// https://eslint.org/docs/rules/block-scoped-var
'block-scoped-var': 'error',
// specify the maximum cyclomatic complexity allowed in a program
'complexity': [0, 11],
// https://eslint.org/docs/rules/complexity
complexity: ['off', 20],
// enforce that class methods use "this"
// https://eslint.org/docs/rules/class-methods-use-this
'class-methods-use-this': ['error', {
exceptMethods: [],
}],
// require return statements to either always or never specify values
'consistent-return': 2,
// https://eslint.org/docs/rules/consistent-return
'consistent-return': 'error',
// specify curly brace conventions for all control statements
'curly': [2, 'multi-line'],
// https://eslint.org/docs/rules/curly
curly: ['error', 'multi-line'], // multiline
// require default case in switch statements
'default-case': [2, { 'commentPattern': '^no default$' }],
// https://eslint.org/docs/rules/default-case
'default-case': ['error', { commentPattern: '^no default$' }],
// Enforce default clauses in switch statements to be last
// https://eslint.org/docs/rules/default-case-last
'default-case-last': 'error',
// https://eslint.org/docs/rules/default-param-last
'default-param-last': 'error',
// encourages use of dot notation whenever possible
'dot-notation': [2, { 'allowKeywords': true }],
// https://eslint.org/docs/rules/dot-notation
'dot-notation': ['error', { allowKeywords: true }],
// enforces consistent newlines before or after dots
'dot-location': 0,
// https://eslint.org/docs/rules/dot-location
'dot-location': ['error', 'property'],
// require the use of === and !==
// http://eslint.org/docs/rules/eqeqeq
'eqeqeq': [2, 'allow-null'],
// https://eslint.org/docs/rules/eqeqeq
eqeqeq: ['error', 'always', { null: 'ignore' }],
// Require grouped accessor pairs in object literals and classes
// https://eslint.org/docs/rules/grouped-accessor-pairs
'grouped-accessor-pairs': 'error',
// make sure for-in loops have an if statement
'guard-for-in': 2,
// Blacklist certain identifiers to prevent them being used
// http://eslint.org/docs/rules/id-blacklist
'id-blacklist': 0,
// https://eslint.org/docs/rules/guard-for-in
'guard-for-in': 'error',
// enforce a maximum number of classes per file
// https://eslint.org/docs/rules/max-classes-per-file
'max-classes-per-file': ['error', 1],
// disallow the use of alert, confirm, and prompt
'no-alert': 1,
// https://eslint.org/docs/rules/no-alert
// TODO: enable, semver-major
'no-alert': 'warn',
// disallow use of arguments.caller or arguments.callee
'no-caller': 2,
// https://eslint.org/docs/rules/no-caller
'no-caller': 'error',
// disallow lexical declarations in case/default clauses
// http://eslint.org/docs/rules/no-case-declarations.html
'no-case-declarations': 2,
// https://eslint.org/docs/rules/no-case-declarations
'no-case-declarations': 'error',
// Disallow returning value in constructor
// https://eslint.org/docs/rules/no-constructor-return
'no-constructor-return': 'error',
// disallow division operators explicitly at beginning of regular expression
'no-div-regex': 0,
// https://eslint.org/docs/rules/no-div-regex
'no-div-regex': 'off',
// disallow else after a return in an if
'no-else-return': 2,
// https://eslint.org/docs/rules/no-else-return
'no-else-return': ['error', { allowElseIf: false }],
// disallow empty functions, except for standalone funcs/arrows
// http://eslint.org/docs/rules/no-empty-function
'no-empty-function': [2, {
'allow': [
// https://eslint.org/docs/rules/no-empty-function
'no-empty-function': ['error', {
allow: [
'arrowFunctions',
'functions',
'methods',
]
}],
// disallow empty destructuring patterns
// http://eslint.org/docs/rules/no-empty-pattern
'no-empty-pattern': 2,
// disallow Unnecessary Labels
// http://eslint.org/docs/rules/no-extra-label
'no-extra-label': 2,
// https://eslint.org/docs/rules/no-empty-pattern
'no-empty-pattern': 'error',
// Disallow empty static blocks
// https://eslint.org/docs/latest/rules/no-empty-static-block
// TODO: semver-major, enable
'no-empty-static-block': 'off',
// disallow comparisons to null without a type-checking operator
'no-eq-null': 0,
// https://eslint.org/docs/rules/no-eq-null
'no-eq-null': 'off',
// disallow use of eval()
'no-eval': 2,
// https://eslint.org/docs/rules/no-eval
'no-eval': 'error',
// disallow adding to native types
'no-extend-native': 2,
// https://eslint.org/docs/rules/no-extend-native
'no-extend-native': 'error',
// disallow unnecessary function binding
'no-extra-bind': 2,
// https://eslint.org/docs/rules/no-extra-bind
'no-extra-bind': 'error',
// disallow Unnecessary Labels
// https://eslint.org/docs/rules/no-extra-label
'no-extra-label': 'error',
// disallow fallthrough of case statements
'no-fallthrough': 2,
// https://eslint.org/docs/rules/no-fallthrough
'no-fallthrough': 'error',
// 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 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 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,
// https://eslint.org/docs/rules/no-floating-decimal
'no-floating-decimal': 'error',
// disallow reassignments of native objects or read-only globals
// https://eslint.org/docs/rules/no-global-assign
'no-global-assign': ['error', { exceptions: [] }],
// deprecated in favor of no-global-assign
// https://eslint.org/docs/rules/no-native-reassign
'no-native-reassign': 'off',
// disallow implicit type conversions
// https://eslint.org/docs/rules/no-implicit-coercion
'no-implicit-coercion': ['off', {
boolean: false,
number: true,
string: true,
allow: [],
}],
// disallow var and named functions in global scope
// https://eslint.org/docs/rules/no-implicit-globals
'no-implicit-globals': 'off',
// disallow use of eval()-like methods
// https://eslint.org/docs/rules/no-implied-eval
'no-implied-eval': 'error',
// disallow this keywords outside of classes or class-like objects
// https://eslint.org/docs/rules/no-invalid-this
'no-invalid-this': 'off',
// disallow usage of __iterator__ property
// https://eslint.org/docs/rules/no-iterator
'no-iterator': 'error',
// disallow use of labels for anything other than loops and switches
// https://eslint.org/docs/rules/no-labels
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
// disallow unnecessary nested blocks
// https://eslint.org/docs/rules/no-lone-blocks
'no-lone-blocks': 'error',
// disallow creation of functions within loops
// https://eslint.org/docs/rules/no-loop-func
'no-loop-func': 'error',
// disallow magic numbers
// https://eslint.org/docs/rules/no-magic-numbers
'no-magic-numbers': ['off', {
ignore: [],
ignoreArrayIndexes: true,
enforceConst: true,
detectObjects: false,
}],
// disallow use of multiple spaces
'no-multi-spaces': 2,
// https://eslint.org/docs/rules/no-multi-spaces
'no-multi-spaces': ['error', {
ignoreEOLComments: false,
}],
// disallow use of multiline strings
'no-multi-str': 2,
// disallow reassignments of native objects
'no-native-reassign': 2,
// https://eslint.org/docs/rules/no-multi-str
'no-multi-str': 'error',
// disallow use of new operator when not part of the assignment or comparison
'no-new': 2,
// https://eslint.org/docs/rules/no-new
'no-new': 'error',
// disallow use of new operator for Function object
'no-new-func': 2,
// https://eslint.org/docs/rules/no-new-func
'no-new-func': 'error',
// disallows creating new instances of String, Number, and Boolean
'no-new-wrappers': 2,
// https://eslint.org/docs/rules/no-new-wrappers
'no-new-wrappers': 'error',
// Disallow \8 and \9 escape sequences in string literals
// https://eslint.org/docs/rules/no-nonoctal-decimal-escape
'no-nonoctal-decimal-escape': 'error',
// disallow use of (old style) octal literals
'no-octal': 2,
// https://eslint.org/docs/rules/no-octal
'no-octal': 'error',
// disallow use of octal escape sequences in string literals, such as
// var foo = 'Copyright \251';
'no-octal-escape': 2,
// https://eslint.org/docs/rules/no-octal-escape
'no-octal-escape': 'error',
// disallow reassignment of function parameters
// disallow parameter object manipulation
// rule: http://eslint.org/docs/rules/no-param-reassign.html
'no-param-reassign': [2, { 'props': true }],
// disallow use of process.env
'no-process-env': 0,
// disallow parameter object manipulation except for specific exclusions
// rule: https://eslint.org/docs/rules/no-param-reassign.html
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: [
'acc', // for reduce accumulators
'accumulator', // for reduce accumulators
'e', // for e.returnvalue
'ctx', // for Koa routing
'context', // for Koa routing
'req', // for Express requests
'request', // for Express requests
'res', // for Express responses
'response', // for Express responses
'$scope', // for Angular 1 scopes
'staticContext', // for ReactRouter context
]
}],
// disallow usage of __proto__ property
'no-proto': 2,
// disallow declaring the same variable more then once
'no-redeclare': 2,
// disallow certain syntax forms
// http://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': [
2,
'DebuggerStatement',
'ForInStatement',
'LabeledStatement',
'WithStatement',
],
// https://eslint.org/docs/rules/no-proto
'no-proto': 'error',
// disallow declaring the same variable more than once
// https://eslint.org/docs/rules/no-redeclare
'no-redeclare': 'error',
// disallow certain object properties
// https://eslint.org/docs/rules/no-restricted-properties
'no-restricted-properties': ['error', {
object: 'arguments',
property: 'callee',
message: 'arguments.callee is deprecated',
}, {
object: 'global',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'self',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'window',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'global',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
object: 'self',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
object: 'window',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
property: '__defineGetter__',
message: 'Please use Object.defineProperty instead.',
}, {
property: '__defineSetter__',
message: 'Please use Object.defineProperty instead.',
}, {
object: 'Math',
property: 'pow',
message: 'Use the exponentiation operator (**) instead.',
}],
// disallow use of assignment in return statement
'no-return-assign': 2,
// https://eslint.org/docs/rules/no-return-assign
'no-return-assign': ['error', 'always'],
// disallow redundant `return await`
// https://eslint.org/docs/rules/no-return-await
'no-return-await': 'error',
// disallow use of `javascript:` urls.
'no-script-url': 2,
// https://eslint.org/docs/rules/no-script-url
'no-script-url': 'error',
// disallow self assignment
// https://eslint.org/docs/rules/no-self-assign
'no-self-assign': ['error', {
props: true,
}],
// disallow comparisons where both sides are exactly the same
'no-self-compare': 2,
// https://eslint.org/docs/rules/no-self-compare
'no-self-compare': 'error',
// disallow use of comma operator
'no-sequences': 2,
// https://eslint.org/docs/rules/no-sequences
'no-sequences': 'error',
// restrict what can be thrown as an exception
'no-throw-literal': 2,
// https://eslint.org/docs/rules/no-throw-literal
'no-throw-literal': 'error',
// disallow unmodified conditions of loops
// http://eslint.org/docs/rules/no-unmodified-loop-condition
'no-unmodified-loop-condition': 0,
// disallow return/throw/break/continue inside finally blocks
// http://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 2,
// https://eslint.org/docs/rules/no-unmodified-loop-condition
'no-unmodified-loop-condition': 'off',
// disallow usage of expressions in statement position
'no-unused-expressions': 2,
// https://eslint.org/docs/rules/no-unused-expressions
'no-unused-expressions': ['error', {
allowShortCircuit: false,
allowTernary: false,
allowTaggedTemplates: false,
}],
// disallow unused labels
// http://eslint.org/docs/rules/no-unused-labels
'no-unused-labels': 2,
// https://eslint.org/docs/rules/no-unused-labels
'no-unused-labels': 'error',
// disallow unnecessary .call() and .apply()
'no-useless-call': 0,
// https://eslint.org/docs/rules/no-useless-call
'no-useless-call': 'off',
// Disallow unnecessary catch clauses
// https://eslint.org/docs/rules/no-useless-catch
'no-useless-catch': 'error',
// disallow useless string concatenation
// http://eslint.org/docs/rules/no-useless-concat
'no-useless-concat': 2,
// https://eslint.org/docs/rules/no-useless-concat
'no-useless-concat': 'error',
// disallow unnecessary string escaping
// http://eslint.org/docs/rules/no-useless-escape
'no-useless-escape': 2,
// https://eslint.org/docs/rules/no-useless-escape
'no-useless-escape': 'error',
// disallow redundant return; keywords
// https://eslint.org/docs/rules/no-useless-return
'no-useless-return': 'error',
// disallow use of void operator
'no-void': 0,
// https://eslint.org/docs/rules/no-void
'no-void': 'error',
// disallow usage of configurable warning terms in comments: e.g. todo
'no-warning-comments': [0, { 'terms': ['todo', 'fixme', 'xxx'], 'location': 'start' }],
// https://eslint.org/docs/rules/no-warning-comments
'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
// disallow use of the with statement
'no-with': 2,
// https://eslint.org/docs/rules/no-with
'no-with': 'error',
// require using Error objects as Promise rejection reasons
// https://eslint.org/docs/rules/prefer-promise-reject-errors
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
// Suggest using named capture group in regular expression
// https://eslint.org/docs/rules/prefer-named-capture-group
'prefer-named-capture-group': 'off',
// Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call()
// https://eslint.org/docs/rules/prefer-object-has-own
// TODO: semver-major: enable thus rule, once eslint v8.5.0 is required
'prefer-object-has-own': 'off',
// https://eslint.org/docs/rules/prefer-regex-literals
'prefer-regex-literals': ['error', {
disallowRedundantWrapping: true,
}],
// require use of the second argument for parseInt()
'radix': 2,
// https://eslint.org/docs/rules/radix
radix: 'error',
// require `await` in `async function` (note: this is a horrible rule that should never be used)
// https://eslint.org/docs/rules/require-await
'require-await': 'off',
// Enforce the use of u flag on RegExp
// https://eslint.org/docs/rules/require-unicode-regexp
'require-unicode-regexp': 'off',
// requires to declare all vars on top of their containing scope
'vars-on-top': 2,
// https://eslint.org/docs/rules/vars-on-top
'vars-on-top': 'error',
// require immediate function invocation to be wrapped in parentheses
// http://eslint.org/docs/rules/wrap-iife.html
'wrap-iife': [2, 'outside'],
// https://eslint.org/docs/rules/wrap-iife.html
'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
// require or disallow Yoda conditions
'yoda': 2
// https://eslint.org/docs/rules/yoda
yoda: 'error'
}
};

View File

@@ -1,63 +1,189 @@
module.exports = {
'rules': {
rules: {
// Enforce “for” loop update clause moving the counter in the right direction
// https://eslint.org/docs/rules/for-direction
'for-direction': 'error',
// Enforces that a return statement is present in property getters
// https://eslint.org/docs/rules/getter-return
'getter-return': ['error', { allowImplicit: true }],
// disallow using an async function as a Promise executor
// https://eslint.org/docs/rules/no-async-promise-executor
'no-async-promise-executor': 'error',
// Disallow await inside of loops
// https://eslint.org/docs/rules/no-await-in-loop
'no-await-in-loop': 'error',
// Disallow comparisons to negative zero
// https://eslint.org/docs/rules/no-compare-neg-zero
'no-compare-neg-zero': 'error',
// disallow assignment in conditional expressions
'no-cond-assign': [2, 'always'],
'no-cond-assign': ['error', 'always'],
// disallow use of console
'no-console': 1,
'no-console': 'warn',
// Disallows expressions where the operation doesn't affect the value
// https://eslint.org/docs/rules/no-constant-binary-expression
// TODO: semver-major, enable
'no-constant-binary-expression': 'off',
// disallow use of constant expressions in conditions
'no-constant-condition': 1,
'no-constant-condition': 'warn',
// disallow control characters in regular expressions
'no-control-regex': 2,
'no-control-regex': 'error',
// disallow use of debugger
'no-debugger': 2,
'no-debugger': 'error',
// disallow duplicate arguments in functions
'no-dupe-args': 2,
'no-dupe-args': 'error',
// Disallow duplicate conditions in if-else-if chains
// https://eslint.org/docs/rules/no-dupe-else-if
'no-dupe-else-if': 'error',
// disallow duplicate keys when creating object literals
'no-dupe-keys': 2,
'no-dupe-keys': 'error',
// disallow a duplicate case label.
'no-duplicate-case': 2,
// disallow the use of empty character classes in regular expressions
'no-empty-character-class': 2,
'no-duplicate-case': 'error',
// disallow empty statements
'no-empty': 2,
'no-empty': 'error',
// disallow the use of empty character classes in regular expressions
'no-empty-character-class': 'error',
// disallow assigning to the exception in a catch block
'no-ex-assign': 2,
'no-ex-assign': 'error',
// disallow double-negation boolean casts in a boolean context
'no-extra-boolean-cast': 0,
// https://eslint.org/docs/rules/no-extra-boolean-cast
'no-extra-boolean-cast': 'error',
// disallow unnecessary parentheses
// http://eslint.org/docs/rules/no-extra-parens
'no-extra-parens': [0, 'all', {
'conditionalAssign': true,
'nestedBinaryExpressions': false,
// https://eslint.org/docs/rules/no-extra-parens
'no-extra-parens': ['off', 'all', {
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: false,
ignoreJSX: 'all', // delegate to eslint-plugin-react
enforceForArrowConditionals: false,
}],
// disallow unnecessary semicolons
'no-extra-semi': 2,
'no-extra-semi': 'error',
// disallow overwriting functions written as function declarations
'no-func-assign': 2,
'no-func-assign': 'error',
// https://eslint.org/docs/rules/no-import-assign
'no-import-assign': 'error',
// disallow function or variable declarations in nested blocks
'no-inner-declarations': 2,
'no-inner-declarations': 'error',
// disallow invalid regular expression strings in the RegExp constructor
'no-invalid-regexp': 2,
'no-invalid-regexp': 'error',
// 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,
'no-irregular-whitespace': 'error',
// Disallow Number Literals That Lose Precision
// https://eslint.org/docs/rules/no-loss-of-precision
'no-loss-of-precision': 'error',
// Disallow characters which are made with multiple code points in character class syntax
// https://eslint.org/docs/rules/no-misleading-character-class
'no-misleading-character-class': 'error',
// disallow the use of object properties of the global object (Math and JSON) as functions
'no-obj-calls': 2,
'no-obj-calls': 'error',
// Disallow new operators with global non-constructor functions
// https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
// TODO: semver-major, enable
'no-new-native-nonconstructor': 'off',
// Disallow returning values from Promise executor functions
// https://eslint.org/docs/rules/no-promise-executor-return
'no-promise-executor-return': 'error',
// disallow use of Object.prototypes builtins directly
// https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'error',
// disallow multiple spaces in a regular expression literal
'no-regex-spaces': 2,
'no-regex-spaces': 'error',
// Disallow returning values from setters
// https://eslint.org/docs/rules/no-setter-return
'no-setter-return': 'error',
// disallow sparse arrays
'no-sparse-arrays': 2,
// disallow unreachable statements after a return, throw, continue, or break statement
'no-unreachable': 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,
'no-sparse-arrays': 'error',
// Disallow template literal placeholder syntax in regular strings
// https://eslint.org/docs/rules/no-template-curly-in-string
'no-template-curly-in-string': 'error',
// Avoid code that looks like two expressions but is actually one
'no-unexpected-multiline': 0
// https://eslint.org/docs/rules/no-unexpected-multiline
'no-unexpected-multiline': 'error',
// disallow unreachable statements after a return, throw, continue, or break statement
'no-unreachable': 'error',
// Disallow loops with a body that allows only one iteration
// https://eslint.org/docs/rules/no-unreachable-loop
'no-unreachable-loop': ['error', {
ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
}],
// disallow return/throw/break/continue inside finally blocks
// https://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 'error',
// disallow negating the left operand of relational operators
// https://eslint.org/docs/rules/no-unsafe-negation
'no-unsafe-negation': 'error',
// disallow use of optional chaining in contexts where the undefined value is not allowed
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
// Disallow Unused Private Class Members
// https://eslint.org/docs/rules/no-unused-private-class-members
// TODO: enable once eslint 7 is dropped (which is semver-major)
'no-unused-private-class-members': 'off',
// Disallow useless backreferences in regular expressions
// https://eslint.org/docs/rules/no-useless-backreference
'no-useless-backreference': 'error',
// disallow negation of the left operand of an in expression
// deprecated in favor of no-unsafe-negation
'no-negated-in-lhs': 'off',
// Disallow assignments that can lead to race conditions due to usage of await or yield
// https://eslint.org/docs/rules/require-atomic-updates
// note: not enabled because it is very buggy
'require-atomic-updates': 'off',
// disallow comparisons with the value NaN
'use-isnan': 'error',
// ensure JSDoc comments are valid
// https://eslint.org/docs/rules/valid-jsdoc
'valid-jsdoc': 'off',
// ensure that the results of typeof are compared against a valid string
// https://eslint.org/docs/rules/valid-typeof
'valid-typeof': ['error', { requireStringLiterals: true }],
}
};

View File

@@ -1,174 +1,185 @@
module.exports = {
'env': {
'es6': true
env: {
es6: true
},
'parserOptions': {
'ecmaVersion': 6,
'sourceType': 'module',
'ecmaFeatures': {
'generators': false,
'objectLiteralDuplicateProperties': false
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
generators: false,
objectLiteralDuplicateProperties: false
}
},
'plugins': [
'import'
],
'rules': {
rules: {
// enforces no braces where they can be omitted
// http://eslint.org/docs/rules/arrow-body-style
'arrow-body-style': [2, 'as-needed'],
// https://eslint.org/docs/rules/arrow-body-style
// TODO: enable requireReturnForObjectLiteral?
'arrow-body-style': ['error', 'as-needed', {
requireReturnForObjectLiteral: false,
}],
// require parens in arrow function arguments
'arrow-parens': 0,
// https://eslint.org/docs/rules/arrow-parens
'arrow-parens': ['error', 'always'],
// require space before/after arrow function's arrow
// http://eslint.org/docs/rules/arrow-spacing
'arrow-spacing': [2, { 'before': true, 'after': true }],
// require trailing commas in multiline object literals
'comma-dangle': [2, 'always-multiline'],
// https://eslint.org/docs/rules/arrow-spacing
'arrow-spacing': ['error', { before: true, after: true }],
// verify super() callings in constructors
'constructor-super': 0,
'constructor-super': 'error',
// enforce the spacing around the * in generator functions
'generator-star-spacing': 0,
// https://eslint.org/docs/rules/generator-star-spacing
'generator-star-spacing': ['error', { before: false, after: true }],
// disallow modifying variables of class declarations
// http://eslint.org/docs/rules/no-class-assign
'no-class-assign': 2,
// https://eslint.org/docs/rules/no-class-assign
'no-class-assign': 'error',
// disallow arrow functions where they could be confused with comparisons
// http://eslint.org/docs/rules/no-confusing-arrow
'no-confusing-arrow': [2, {
'allowParens': true,
// https://eslint.org/docs/rules/no-confusing-arrow
'no-confusing-arrow': ['error', {
allowParens: true,
}],
// disallow modifying variables that are declared using const
'no-const-assign': 2,
'no-const-assign': 'error',
// disallow duplicate class members
// http://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 2,
// https://eslint.org/docs/rules/no-dupe-class-members
'no-dupe-class-members': 'error',
// disallow importing from the same path more than once
// http://eslint.org/docs/rules/no-duplicate-imports
'no-duplicate-imports': 2,
// https://eslint.org/docs/rules/no-duplicate-imports
// replaced by https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'no-duplicate-imports': 'off',
// disallow symbol constructor
// http://eslint.org/docs/rules/no-new-symbol
'no-new-symbol': 2,
// disallow specific globals
'no-restricted-globals': 0,
// https://eslint.org/docs/rules/no-new-symbol
'no-new-symbol': 'error',
// Disallow specified names in exports
// https://eslint.org/docs/rules/no-restricted-exports
'no-restricted-exports': ['error', {
restrictedNamedExports: [
'default', // use `export default` to provide a default export
'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
],
}],
// disallow specific imports
// http://eslint.org/docs/rules/no-restricted-imports
'no-restricted-imports': 0,
// https://eslint.org/docs/rules/no-restricted-imports
'no-restricted-imports': ['off', {
paths: [],
patterns: []
}],
// 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,
// https://eslint.org/docs/rules/no-this-before-super
'no-this-before-super': 'error',
// disallow useless computed property keys
// http://eslint.org/docs/rules/no-useless-computed-key
'no-useless-computed-key': 2,
// https://eslint.org/docs/rules/no-useless-computed-key
'no-useless-computed-key': 'error',
// disallow unnecessary constructor
// http://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 2,
// https://eslint.org/docs/rules/no-useless-constructor
'no-useless-constructor': 'error',
// disallow renaming import, export, and destructured assignments to the same name
// https://eslint.org/docs/rules/no-useless-rename
'no-useless-rename': ['error', {
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
}],
// require let or const instead of var
'no-var': 'error',
// require method and property shorthand syntax for object literals
// http://eslint.org/docs/rules/object-shorthand
'object-shorthand': [2, 'always'],
// https://eslint.org/docs/rules/object-shorthand
'object-shorthand': ['error', 'always', {
ignoreConstructors: false,
avoidQuotes: true,
}],
// suggest using arrow functions as callbacks
'prefer-arrow-callback': [2, {
'allowNamedFunctions': false,
'allowUnboundThis': true,
'prefer-arrow-callback': ['error', {
allowNamedFunctions: false,
allowUnboundThis: true,
}],
// 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,
'prefer-const': ['error', {
destructuring: 'any',
ignoreReadBeforeAssign: true,
}],
// Prefer destructuring from arrays and objects
// https://eslint.org/docs/rules/prefer-destructuring
'prefer-destructuring': ['error', {
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: false,
},
}, {
enforceForRenamedProperties: false,
}],
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
// https://eslint.org/docs/rules/prefer-numeric-literals
'prefer-numeric-literals': 'error',
// suggest using Reflect methods where applicable
'prefer-reflect': 0,
// https://eslint.org/docs/rules/prefer-reflect
'prefer-reflect': 'off',
// use rest parameters instead of arguments
// http://eslint.org/docs/rules/prefer-rest-params
'prefer-rest-params': 2,
// https://eslint.org/docs/rules/prefer-rest-params
'prefer-rest-params': 'error',
// suggest using the spread syntax instead of .apply()
// https://eslint.org/docs/rules/prefer-spread
'prefer-spread': 'error',
// suggest using template literals instead of string concatenation
// http://eslint.org/docs/rules/prefer-template
'prefer-template': 2,
// https://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',
// disallow generator functions that do not have yield
'require-yield': 0,
// https://eslint.org/docs/rules/require-yield
'require-yield': 'error',
// enforce spacing between object rest-spread
// https://eslint.org/docs/rules/rest-spread-spacing
'rest-spread-spacing': ['error', 'never'],
// import sorting
// http://eslint.org/docs/rules/sort-imports
'sort-imports': 0,
// https://eslint.org/docs/rules/sort-imports
'sort-imports': ['off', {
ignoreCase: false,
ignoreDeclarationSort: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
}],
// require a Symbol description
// https://eslint.org/docs/rules/symbol-description
'symbol-description': 'error',
// enforce usage of spacing in template strings
// http://eslint.org/docs/rules/template-curly-spacing
'template-curly-spacing': 2,
// https://eslint.org/docs/rules/template-curly-spacing
'template-curly-spacing': 'error',
// enforce spacing around the * in yield* expressions
// http://eslint.org/docs/rules/yield-star-spacing
'yield-star-spacing': [2, 'after'],
// disallow invalid exports, e.g. multiple defaults
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
'import/export': 2,
// 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,
// 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
'import/extensions': [0, 'never'],
// 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,
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
'import/namespace': 0,
// Forbid the use of extraneous packages
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
// TODO: enable
'import/no-extraneous-dependencies': [0, {
'devDependencies': false,
'optionalDependencies': false,
}],
// 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 }],
// 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
// TODO: enable
'import/no-named-as-default': 0,
// 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,
// disallow non-import statements appearing before import statements
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
// TODO: enable?
'import/imports-first': [0, 'absolute-first'],
// disallow duplicate imports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'import/no-duplicates': 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,
// disallow namespace imports
// TODO: enable?
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
'import/no-namespace': 0,
// warn on accessing default export property names that are also named exports
// TODO: enable?
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
'import/no-named-as-default-member': 0,
// No Node.js builtin modules
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
'import/no-nodejs-modules': 0,
// 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
// TODO: enable
'import/newline-after-import': 0,
// Forbid mutable exports
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
'import/no-mutable-exports': 2,
},
'settings': {
'import/resolver': {
'node': {
'extensions': ['.js', '.json']
}
}
// https://eslint.org/docs/rules/yield-star-spacing
'yield-star-spacing': ['error', 'after']
}
};

View File

@@ -0,0 +1,283 @@
module.exports = {
env: {
es6: true
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module'
},
plugins: [
'import'
],
settings: {
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json']
}
},
'import/extensions': [
'.js',
'.mjs',
'.jsx',
],
'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/import-js/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
// ensure named imports coupled with named exports
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
'import/named': 'error',
// ensure default import coupled with default export
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
'import/default': 'off',
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/namespace.md
'import/namespace': 'off',
// Helpful warnings:
// disallow invalid exports, e.g. multiple defaults
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/export.md
'import/export': 'error',
// do not allow a default import name to match a named export
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
'import/no-named-as-default': 'error',
// warn on accessing default export property names that are also named exports
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
'import/no-named-as-default-member': 'error',
// disallow use of jsdoc-marked-deprecated imports
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
'import/no-deprecated': 'off',
// Forbid the use of extraneous packages
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
// paths are treated both as absolute paths, and relative to process.cwd()
'import/no-extraneous-dependencies': ['error', {
devDependencies: [
'test/**', // tape, common npm pattern
'tests/**', // also common npm pattern
'spec/**', // mocha, rspec-like pattern
'**/__tests__/**', // jest pattern
'**/__mocks__/**', // jest pattern
'test.{js,jsx}', // repos with a single test file
'test-*.{js,jsx}', // repos with multiple top-level test files
'**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test
'**/jest.config.js', // jest config
'**/jest.setup.js', // jest setup
'**/vue.config.js', // vue-cli config
'**/webpack.config.js', // webpack config
'**/webpack.config.*.js', // webpack config
'**/rollup.config.js', // rollup config
'**/rollup.config.*.js', // rollup config
'**/gulpfile.js', // gulp config
'**/gulpfile.*.js', // gulp config
'**/Gruntfile{,.js}', // grunt config
'**/protractor.conf.js', // protractor config
'**/protractor.conf.*.js', // protractor config
'**/karma.conf.js', // karma config
'**/.eslintrc.js' // eslint config
],
optionalDependencies: false,
}],
// Forbid mutable exports
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
'import/no-mutable-exports': 'error',
// Module systems:
// disallow require()
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
'import/no-commonjs': 'off',
// disallow AMD require/define
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-amd.md
'import/no-amd': 'error',
// No Node.js builtin modules
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
// TODO: enable?
'import/no-nodejs-modules': 'off',
// Style guide:
// disallow non-import statements appearing before import statements
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/first.md
'import/first': 'error',
// disallow non-import statements appearing before import statements
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/imports-first.md
// deprecated: use `import/first`
'import/imports-first': 'off',
// disallow duplicate imports
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
'import/no-duplicates': 'error',
// disallow namespace imports
// TODO: enable?
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
'import/no-namespace': 'off',
// Ensure consistent use of file extension within the import path
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/extensions.md
'import/extensions': ['error', 'ignorePackages', {
js: 'never',
mjs: 'never',
jsx: 'never',
}],
// ensure absolute imports are above relative imports and that unassigned imports are ignored
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md
// TODO: enforce a stricter convention in module import order?
'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
// Require a newline after the last import/require in a group
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
'import/newline-after-import': 'error',
// Require modules with a single export to use a default export
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
'import/prefer-default-export': 'error',
// Restrict which files can be imported in a given folder
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
'import/no-restricted-paths': 'off',
// Forbid modules to have too many dependencies
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
'import/max-dependencies': ['off', { max: 10 }],
// Forbid import of modules using absolute paths
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
'import/no-absolute-path': 'error',
// Forbid require() calls with expressions
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
'import/no-dynamic-require': 'error',
// prevent importing the submodules of other modules
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
'import/no-internal-modules': ['off', {
allow: [],
}],
// Warn if a module could be mistakenly parsed as a script by a consumer
// leveraging Unambiguous JavaScript Grammar
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
// this should not be enabled until this proposal has at least been *presented* to TC39.
// At the moment, it's not a thing.
'import/unambiguous': 'off',
// Forbid Webpack loader syntax in imports
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
'import/no-webpack-loader-syntax': 'error',
// Prevent unassigned imports
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
// importing for side effects is perfectly acceptable, if you need side effects.
'import/no-unassigned-import': 'off',
// Prevent importing the default as if it were named
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
'import/no-named-default': 'error',
// Reports if a module's default export is unnamed
// https://github.com/import-js/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
'import/no-anonymous-default-export': ['off', {
allowArray: false,
allowArrowFunction: false,
allowAnonymousClass: false,
allowAnonymousFunction: false,
allowLiteral: false,
allowObject: false,
}],
// This rule enforces that all exports are declared at the bottom of the file.
// https://github.com/import-js/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md
// TODO: enable?
'import/exports-last': 'off',
// Reports when named exports are not grouped together in a single export declaration
// or when multiple assignments to CommonJS module.exports or exports object are present
// in a single file.
// https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md
'import/group-exports': 'off',
// forbid default exports. this is a terrible rule, do not use it.
// https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md
'import/no-default-export': 'off',
// Prohibit named exports. this is a terrible rule, do not use it.
// https://github.com/import-js/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md
'import/no-named-export': 'off',
// Forbid a module from importing itself
// https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md
'import/no-self-import': 'error',
// Forbid cyclical dependencies between modules
// https://github.com/import-js/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md
'import/no-cycle': ['error', { maxDepth: '∞' }],
// Ensures that there are no useless path segments
// https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md
'import/no-useless-path-segments': ['error', { commonjs: true }],
// dynamic imports require a leading comment with a webpackChunkName
// https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md
'import/dynamic-import-chunkname': ['off', {
importFunctions: [],
webpackChunknameFormat: '[0-9a-zA-Z-_/.]+',
}],
// Use this rule to prevent imports to folders in relative parent paths.
// https://github.com/import-js/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md
'import/no-relative-parent-imports': 'off',
// Reports modules without any exports, or with unused exports
// https://github.com/import-js/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
// TODO: enable once it supports CJS
'import/no-unused-modules': ['off', {
ignoreExports: [],
missingExports: true,
unusedExports: true,
}],
// Reports the use of import declarations with CommonJS exports in any module except for the main module.
// https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
'import/no-import-module-exports': ['error', {
exceptions: [],
}],
// Use this rule to prevent importing packages through relative paths.
// https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md
'import/no-relative-packages': 'error',
// enforce a consistent style for type specifiers (inline or top-level)
// https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/consistent-type-specifier-style.md
// TODO, semver-major: enable (just in case)
'import/consistent-type-specifier-style': ['off', 'prefer-inline'],
// Reports the use of empty named import blocks.
// https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/no-empty-named-blocks.md
// TODO, semver-minor: enable
'import/no-empty-named-blocks': 'off',
},
};

View File

@@ -1,16 +0,0 @@
module.exports = {
'rules': {
// disallow trailing commas in object literals
'comma-dangle': [2, 'never'],
// specify the maximum depth that blocks can be nested
'max-depth': [0, 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

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

View File

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

View File

@@ -1,156 +1,534 @@
module.exports = {
'rules': {
rules: {
// enforce line breaks after opening and before closing array brackets
// https://eslint.org/docs/rules/array-bracket-newline
// TODO: enable? semver-major
'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 }
// enforce line breaks between array elements
// https://eslint.org/docs/rules/array-element-newline
// TODO: enable? semver-major
'array-element-newline': ['off', { multiline: true, minItems: 3 }],
// enforce spacing inside array brackets
'array-bracket-spacing': [2, 'never'],
'array-bracket-spacing': ['error', 'never'],
// enforce spacing inside single-line blocks
// http://eslint.org/docs/rules/block-spacing
'block-spacing': [2, 'always'],
// https://eslint.org/docs/rules/block-spacing
'block-spacing': ['error', 'always'],
// enforce one true brace style
'brace-style': [2, '1tbs', { 'allowSingleLine': true }],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
// require camel case names
'camelcase': [2, { 'properties': 'never' }],
camelcase: ['error', { properties: 'never', ignoreDestructuring: false }],
// enforce or disallow capitalization of the first letter of a comment
// https://eslint.org/docs/rules/capitalized-comments
'capitalized-comments': ['off', 'never', {
line: {
ignorePattern: '.*',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
block: {
ignorePattern: '.*',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
}],
// require trailing commas in multiline object literals
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
}],
// enforce spacing before and after comma
'comma-spacing': [2, { 'before': false, 'after': true }],
'comma-spacing': ['error', { 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,
// this option enforces minimum and maximum identifier lengths
// (variable names, property names etc.)
'id-length': 0,
// this option sets a specific tab width for your code
// http://eslint.org/docs/rules/indent
'indent': [2, 2, { 'SwitchCase': 1, 'VariableDeclarator': 1 }],
// specify whether double or single quotes should be used in JSX attributes
// http://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': 0,
// 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 }
'comma-style': ['error', 'last', {
exceptions: {
ArrayExpression: false,
ArrayPattern: false,
ArrowFunctionExpression: false,
CallExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
ImportDeclaration: false,
ObjectExpression: false,
ObjectPattern: false,
VariableDeclaration: false,
NewExpression: false,
}
}],
// enforces empty lines around comments
'lines-around-comment': 0,
// disallow mixed 'LF' and 'CRLF' as linebreaks
'linebreak-style': 0,
// 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
// disallow padding inside computed properties
'computed-property-spacing': ['error', 'never'],
// enforces consistent naming when capturing the current execution context
'consistent-this': 'off',
// enforce newline at the end of file, with no multiple empty lines
'eol-last': ['error', 'always'],
// https://eslint.org/docs/rules/function-call-argument-newline
'function-call-argument-newline': ['error', 'consistent'],
// enforce spacing between functions and their invocations
// https://eslint.org/docs/rules/func-call-spacing
'func-call-spacing': ['error', 'never'],
// requires function names to match the name of the variable or property to which they are
// assigned
// https://eslint.org/docs/rules/func-name-matching
'func-name-matching': ['off', 'always', {
includeCommonJSModuleExports: false,
considerPropertyDescriptor: true,
}],
// require function expressions to have a name
// https://eslint.org/docs/rules/func-names
'func-names': 'warn',
// enforces use of function declarations or expressions
// https://eslint.org/docs/rules/func-style
// TODO: enable
'func-style': ['off', 'expression'],
// require line breaks inside function parentheses if there are line breaks between parameters
// https://eslint.org/docs/rules/function-paren-newline
'function-paren-newline': ['error', 'multiline-arguments'],
// disallow specified identifiers
// https://eslint.org/docs/rules/id-denylist
'id-denylist': 'off',
// this option enforces minimum and maximum identifier lengths
// (variable names, property names etc.)
'id-length': 'off',
// require identifiers to match the provided regular expression
'id-match': 'off',
// Enforce the location of arrow function bodies with implicit returns
// https://eslint.org/docs/rules/implicit-arrow-linebreak
'implicit-arrow-linebreak': ['error', 'beside'],
// this option sets a specific tab width for your code
// https://eslint.org/docs/rules/indent
indent: ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
// MemberExpression: null,
FunctionDeclaration: {
parameters: 1,
body: 1
},
FunctionExpression: {
parameters: 1,
body: 1
},
CallExpression: {
arguments: 1
},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
// list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'],
ignoreComments: false
}],
// specify whether double or single quotes should be used in JSX attributes
// https://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': ['off', 'prefer-double'],
// enforces spacing between keys and values in object literal properties
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
// require a space before & after certain keywords
'keyword-spacing': ['error', {
before: true,
after: true,
overrides: {
return: { after: true },
throw: { after: true },
case: { after: true }
}
}],
// enforce position of line comments
// https://eslint.org/docs/rules/line-comment-position
// TODO: enable?
'line-comment-position': ['off', {
position: 'above',
ignorePattern: '',
applyDefaultPatterns: true,
}],
// disallow mixed 'LF' and 'CRLF' as linebreaks
// https://eslint.org/docs/rules/linebreak-style
'linebreak-style': ['error', 'unix'],
// require or disallow an empty line between class members
// https://eslint.org/docs/rules/lines-between-class-members
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }],
// enforces empty lines around comments
'lines-around-comment': 'off',
// require or disallow newlines around directives
// https://eslint.org/docs/rules/lines-around-directive
'lines-around-directive': ['error', {
before: 'always',
after: 'always',
}],
// Require or disallow logical assignment logical operator shorthand
// https://eslint.org/docs/latest/rules/logical-assignment-operators
// TODO, semver-major: enable
'logical-assignment-operators': ['off', 'always', {
enforceForIfStatements: true,
}],
// specify the maximum depth that blocks can be nested
'max-depth': ['off', 4],
// specify the maximum length of a line in your program
// https://eslint.org/docs/rules/max-len
'max-len': ['error', 100, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
// specify the max number of lines in a file
// https://eslint.org/docs/rules/max-lines
'max-lines': ['off', {
max: 300,
skipBlankLines: true,
skipComments: true
}],
// enforce a maximum function length
// https://eslint.org/docs/rules/max-lines-per-function
'max-lines-per-function': ['off', {
max: 50,
skipBlankLines: true,
skipComments: true,
IIFEs: true,
}],
// specify the maximum depth callbacks can be nested
'max-nested-callbacks': 0,
'max-nested-callbacks': 'off',
// limits the number of parameters that can be used in the function declaration.
'max-params': ['off', 3],
// specify the maximum number of statement allowed in a function
'max-statements': ['off', 10],
// restrict the number of statements per line
// http://eslint.org/docs/rules/max-statements-per-line
'max-statements-per-line': [0, { 'max': 1 }],
// https://eslint.org/docs/rules/max-statements-per-line
'max-statements-per-line': ['off', { max: 1 }],
// enforce a particular style for multiline comments
// https://eslint.org/docs/rules/multiline-comment-style
'multiline-comment-style': ['off', 'starred-block'],
// require multiline ternary
// https://eslint.org/docs/rules/multiline-ternary
// TODO: enable?
'multiline-ternary': ['off', 'never'],
// require a capital letter for constructors
'new-cap': [2, { 'newIsCap': true }],
'new-cap': ['error', {
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
}],
// disallow the omission of parentheses when invoking a constructor with no arguments
'new-parens': 0,
// https://eslint.org/docs/rules/new-parens
'new-parens': 'error',
// allow/disallow an empty newline after var statement
'newline-after-var': 0,
// http://eslint.org/docs/rules/newline-before-return
'newline-before-return': 0,
'newline-after-var': 'off',
// https://eslint.org/docs/rules/newline-before-return
'newline-before-return': 'off',
// 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': 3 }],
// https://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
// disallow use of the Array constructor
'no-array-constructor': 2,
'no-array-constructor': 'error',
// disallow use of bitwise operators
// https://eslint.org/docs/rules/no-bitwise
'no-bitwise': 'error',
// disallow use of the continue statement
'no-continue': 0,
// https://eslint.org/docs/rules/no-continue
'no-continue': 'error',
// disallow comments inline after code
'no-inline-comments': 0,
'no-inline-comments': 'off',
// disallow if as the only statement in an else block
'no-lonely-if': 0,
// https://eslint.org/docs/rules/no-lonely-if
'no-lonely-if': 'error',
// disallow un-paren'd mixes of different operators
// https://eslint.org/docs/rules/no-mixed-operators
'no-mixed-operators': ['error', {
// the list of arithmetic groups disallows mixing `%` and `**`
// with other arithmetic operators.
groups: [
['%', '**'],
['%', '+'],
['%', '-'],
['%', '*'],
['%', '/'],
['/', '*'],
['&', '|', '<<', '>>', '>>>'],
['==', '!=', '===', '!=='],
['&&', '||'],
],
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 }],
'no-mixed-spaces-and-tabs': 'error',
// disallow use of chained assignment expressions
// https://eslint.org/docs/rules/no-multi-assign
'no-multi-assign': ['error'],
// disallow multiple empty lines, only one newline at the end, and no new lines at the beginning
// https://eslint.org/docs/rules/no-multiple-empty-lines
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
// disallow negated conditions
// http://eslint.org/docs/rules/no-negated-condition
'no-negated-condition': 0,
// https://eslint.org/docs/rules/no-negated-condition
'no-negated-condition': 'off',
// disallow nested ternary expressions
'no-nested-ternary': 2,
'no-nested-ternary': 'error',
// disallow use of the Object constructor
'no-new-object': 2,
'no-new-object': 'error',
// disallow use of unary operators, ++ and --
// https://eslint.org/docs/rules/no-plusplus
'no-plusplus': 'error',
// disallow certain syntax forms
// https://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'ForOfStatement',
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
// disallow space between function identifier and application
'no-spaced-func': 2,
// deprecated in favor of func-call-spacing
'no-spaced-func': 'off',
// disallow tab characters entirely
'no-tabs': 'error',
// disallow the use of ternary operators
'no-ternary': 0,
'no-ternary': 'off',
// disallow trailing whitespace at the end of lines
'no-trailing-spaces': 2,
'no-trailing-spaces': ['error', {
skipBlankLines: false,
ignoreComments: false,
}],
// disallow dangling underscores in identifiers
'no-underscore-dangle': [2, { 'allowAfterThis': false }],
// https://eslint.org/docs/rules/no-underscore-dangle
'no-underscore-dangle': ['error', {
allow: [],
allowAfterThis: false,
allowAfterSuper: false,
enforceInMethodNames: true,
}],
// 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 }],
// https://eslint.org/docs/rules/no-unneeded-ternary
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
// disallow whitespace before properties
// http://eslint.org/docs/rules/no-whitespace-before-property
'no-whitespace-before-property': 2,
// https://eslint.org/docs/rules/no-whitespace-before-property
'no-whitespace-before-property': 'error',
// enforce the location of single-line statements
// https://eslint.org/docs/rules/nonblock-statement-body-position
'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }],
// require padding inside curly braces
'object-curly-spacing': [2, 'always'],
// 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
'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
// 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', 'avoid-escape'],
// require identifiers to match the provided regular expression
'id-match': 0,
// do not require jsdoc
// http://eslint.org/docs/rules/require-jsdoc
'require-jsdoc': 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 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
'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
'object-curly-spacing': ['error', 'always'],
// enforce line breaks between braces
// https://eslint.org/docs/rules/object-curly-newline
'object-curly-newline': ['error', {
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
}],
// enforce "same line" or "multiple line" on object properties.
// https://eslint.org/docs/rules/object-property-newline
'object-property-newline': ['error', {
allowAllPropertiesOnSameLine: true,
}],
// allow just one var statement per function
'one-var': ['error', 'never'],
// require a newline around variable declaration
// https://eslint.org/docs/rules/one-var-declaration-per-line
'one-var-declaration-per-line': ['error', 'always'],
// require assignment operator shorthand where possible or prohibit it entirely
// https://eslint.org/docs/rules/operator-assignment
'operator-assignment': ['error', 'always'],
// Requires operator at the beginning of the line in multiline statements
// https://eslint.org/docs/rules/operator-linebreak
'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }],
// disallow padding within blocks
'padded-blocks': ['error', {
blocks: 'never',
classes: 'never',
switches: 'never',
}, {
allowSingleLineBlocks: true,
}],
// Require or disallow padding lines between statements
// https://eslint.org/docs/rules/padding-line-between-statements
'padding-line-between-statements': 'off',
// Disallow the use of Math.pow in favor of the ** operator
// https://eslint.org/docs/rules/prefer-exponentiation-operator
'prefer-exponentiation-operator': 'error',
// Prefer use of an object spread over Object.assign
// https://eslint.org/docs/rules/prefer-object-spread
'prefer-object-spread': 'error',
// require quotes around object literal property names
// https://eslint.org/docs/rules/quote-props.html
'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }],
// specify whether double or single quotes should be used
quotes: ['error', 'single', { avoidEscape: true }],
// do not require jsdoc
// https://eslint.org/docs/rules/require-jsdoc
'require-jsdoc': 'off',
// require or disallow use of semicolons instead of ASI
semi: ['error', 'always'],
// enforce spacing before and after semicolons
'semi-spacing': ['error', { before: false, after: true }],
// Enforce location of semicolons
// https://eslint.org/docs/rules/semi-style
'semi-style': ['error', 'last'],
// requires object keys to be sorted
'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }],
// sort variables within the same declaration block
'sort-vars': 'off',
// require or disallow space before blocks
'space-before-blocks': 'error',
// require or disallow space before function opening parenthesis
// https://eslint.org/docs/rules/space-before-function-paren
'space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always'
}],
// require or disallow spaces inside parentheses
'space-in-parens': ['error', 'never'],
// require spaces around operators
'space-infix-ops': 'error',
// Require or disallow spaces before/after unary operators
// https://eslint.org/docs/rules/space-unary-ops
'space-unary-ops': ['error', {
words: true,
nonwords: false,
overrides: {
},
}],
// require or disallow a space immediately following the // or /* in a comment
// https://eslint.org/docs/rules/spaced-comment
'spaced-comment': ['error', 'always', {
line: {
exceptions: ['-', '+'],
markers: ['=', '!', '/'], // space here to support sprockets directives, slash for TS /// comments
},
block: {
exceptions: ['-', '+'],
markers: ['=', '!', ':', '::'], // space here to support sprockets directives and flow comment types
balanced: true,
}
}],
// Enforce spacing around colons of switch statements
// https://eslint.org/docs/rules/switch-colon-spacing
'switch-colon-spacing': ['error', { after: true, before: false }],
// Require or disallow spacing between template tags and their literals
// https://eslint.org/docs/rules/template-tag-spacing
'template-tag-spacing': ['error', 'never'],
// require or disallow the Unicode Byte Order Mark
// https://eslint.org/docs/rules/unicode-bom
'unicode-bom': ['error', 'never'],
// require regex literals to be wrapped in parentheses
'wrap-regex': 0
'wrap-regex': 'off'
}
};

View File

@@ -1,32 +1,56 @@
const confusingBrowserGlobals = require('confusing-browser-globals');
module.exports = {
'rules': {
rules: {
// enforce or disallow variable initializations at definition
'init-declarations': 0,
'init-declarations': 'off',
// disallow the catch clause parameter name being the same as a variable in the outer scope
'no-catch-shadow': 0,
'no-catch-shadow': 'off',
// disallow deletion of variables
'no-delete-var': 2,
// disallow var and named functions in global scope
// http://eslint.org/docs/rules/no-implicit-globals
'no-implicit-globals': 0,
'no-delete-var': 'error',
// disallow labels that share a name with a variable
'no-label-var': 0,
// disallow self assignment
// http://eslint.org/docs/rules/no-self-assign
'no-self-assign': 2,
// disallow shadowing of names such as arguments
'no-shadow-restricted-names': 2,
// https://eslint.org/docs/rules/no-label-var
'no-label-var': 'error',
// disallow specific globals
'no-restricted-globals': [
'error',
{
name: 'isFinite',
message:
'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
},
{
name: 'isNaN',
message:
'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
},
].concat(confusingBrowserGlobals),
// disallow declaration of variables already declared in the outer scope
'no-shadow': 2,
// disallow use of undefined when initializing variables
'no-undef-init': 0,
'no-shadow': 'error',
// disallow shadowing of names such as arguments
'no-shadow-restricted-names': 'error',
// disallow use of undeclared variables unless mentioned in a /*global */ block
'no-undef': 2,
'no-undef': 'error',
// disallow use of undefined when initializing variables
'no-undef-init': 'error',
// disallow use of undefined variable
'no-undefined': 0,
// https://eslint.org/docs/rules/no-undefined
// TODO: enable?
'no-undefined': 'off',
// disallow declaration of variables that are not used in the code
'no-unused-vars': [2, { 'vars': 'local', 'args': 'after-used' }],
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
// disallow use of variables before they are defined
'no-use-before-define': 2
'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
}
};

View File

@@ -1,9 +1,8 @@
{
"rules": {
// disabled because I find it tedious to write tests while following this
// rule
// 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"]}],
}
}

View File

@@ -0,0 +1,13 @@
/* eslint strict: 0, global-require: 0 */
'use strict';
const test = require('tape');
test('all entry points parse', (t) => {
t.doesNotThrow(() => require('..'), 'index does not throw');
t.doesNotThrow(() => require('../legacy'), 'legacy does not throw');
t.doesNotThrow(() => require('../whitespace'), 'whitespace does not throw');
t.end();
});

View File

@@ -2,28 +2,32 @@ import fs from 'fs';
import path from 'path';
import test from 'tape';
const index = require('../');
import index from '..';
const files = { index };
const files = { ...{ index } }; // object spread is to test parsing
fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => {
files[name] = require(`../rules/${name}`); // eslint-disable-line global-require
const rulesDir = path.join(__dirname, '../rules');
fs.readdirSync(rulesDir).forEach((name) => {
// eslint-disable-next-line import/no-dynamic-require
files[name] = require(path.join(rulesDir, name)); // eslint-disable-line global-require
});
Object.keys(files).forEach(name => {
Object.keys(files).forEach((
name, // trailing function comma is to test parsing
) => {
const config = files[name];
test(`${name}: does not reference react`, t => {
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;
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);
.filter((ruleId) => ruleId.indexOf('react/') === 0);
t.deepEquals(reactRuleIds, [], 'there are no react/ rules');
});
});

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env node
const entries = require('object.entries');
const { ESLint } = require('eslint');
const baseConfig = require('.');
const whitespaceRules = require('./whitespaceRules');
const severities = ['off', 'warn', 'error'];
function getSeverity(ruleConfig) {
if (Array.isArray(ruleConfig)) {
return getSeverity(ruleConfig[0]);
}
if (typeof ruleConfig === 'number') {
return severities[ruleConfig];
}
return ruleConfig;
}
async function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = { ...config };
const cli = new ESLint({
useEslintrc: false,
baseConfig: config
});
const baseRules = (await cli.calculateConfigForFile(require.resolve('./'))).rules;
entries(baseRules).forEach((rule) => {
const ruleName = rule[0];
const ruleConfig = rule[1];
const severity = getSeverity(ruleConfig);
if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') {
if (Array.isArray(ruleConfig)) {
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
} else if (typeof ruleConfig === 'number') {
errorsOnly.rules[ruleName] = 1;
} else {
errorsOnly.rules[ruleName] = 'warn';
}
}
});
return errorsOnly;
}
onlyErrorOnRules(whitespaceRules, baseConfig).then((config) => console.log(JSON.stringify(config)));

View File

@@ -0,0 +1,54 @@
/* eslint global-require: 0 */
const { CLIEngine } = require('eslint');
if (CLIEngine) {
/* eslint no-inner-declarations: 0 */
const entries = require('object.entries');
const whitespaceRules = require('./whitespaceRules');
const baseConfig = require('.');
const severities = ['off', 'warn', 'error'];
function getSeverity(ruleConfig) {
if (Array.isArray(ruleConfig)) {
return getSeverity(ruleConfig[0]);
}
if (typeof ruleConfig === 'number') {
return severities[ruleConfig];
}
return ruleConfig;
}
function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = { ...config };
const cli = new CLIEngine({ baseConfig: config, useEslintrc: false });
const baseRules = cli.getConfigForFile(require.resolve('./')).rules;
entries(baseRules).forEach((rule) => {
const ruleName = rule[0];
const ruleConfig = rule[1];
const severity = getSeverity(ruleConfig);
if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') {
if (Array.isArray(ruleConfig)) {
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
} else if (typeof ruleConfig === 'number') {
errorsOnly.rules[ruleName] = 1;
} else {
errorsOnly.rules[ruleName] = 'warn';
}
}
});
return errorsOnly;
}
module.exports = onlyErrorOnRules(whitespaceRules, baseConfig);
} else {
const path = require('path');
const { execSync } = require('child_process');
module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'))));
}

View File

@@ -0,0 +1,49 @@
module.exports = [
'array-bracket-newline',
'array-bracket-spacing',
'array-element-newline',
'arrow-spacing',
'block-spacing',
'comma-spacing',
'computed-property-spacing',
'dot-location',
'eol-last',
'func-call-spacing',
'function-paren-newline',
'generator-star-spacing',
'implicit-arrow-linebreak',
'indent',
'key-spacing',
'keyword-spacing',
'line-comment-position',
'linebreak-style',
'multiline-ternary',
'newline-per-chained-call',
'no-irregular-whitespace',
'no-mixed-spaces-and-tabs',
'no-multi-spaces',
'no-regex-spaces',
'no-spaced-func',
'no-trailing-spaces',
'no-whitespace-before-property',
'nonblock-statement-body-position',
'object-curly-newline',
'object-curly-spacing',
'object-property-newline',
'one-var-declaration-per-line',
'operator-linebreak',
'padded-blocks',
'padding-line-between-statements',
'rest-spread-spacing',
'semi-spacing',
'semi-style',
'space-before-blocks',
'space-before-function-paren',
'space-in-parens',
'space-infix-ops',
'space-unary-ops',
'spaced-comment',
'switch-colon-spacing',
'template-tag-spacing',
'import/newline-after-import'
];

View File

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

View File

@@ -0,0 +1 @@
../../.editorconfig

View File

@@ -3,6 +3,6 @@
"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
}
"comma-dangle": 0,
},
}

View File

@@ -0,0 +1 @@
../../.npmrc

View File

@@ -1,3 +1,256 @@
19.0.4 / 2021-12-25
==================
- republish to fix #2529
19.0.3 / 2021-12-24
==================
- [patch] set `namedComponents` option to match style guide
- [deps] update `eslint-plugin-react`
19.0.2 / 2021-12-02
==================
- [meta] fix "exports" path (#2525)
- [Tests] re-enable tests disabled for the eslint 8 upgrade
19.0.1 / 2021-11-22
==================
- [fix] `whitespace`: update to support eslint 8 (#2517)
- [deps] update `eslint-plugin-react`
- [dev deps] update `tape`
19.0.0 / 2021-11-10
==================
- [breaking] support `eslint` 8; drop `eslint` < 7
- [patch] Explain why `react/jsx-key` is turned off (#2474)
- [fix] bump eslint-plugin-react-hooks peer dependency version (#2356)
- [patch] Alphabetize the rules for react-a11y.js (#2407)
- [Docs] HTTP => HTTPS (#2489)
- [readme] clarify hooks requirement (#2482)
- [deps] update `eslint-config-airbnb-base`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `safe-publish-latest`, `eslint-plugin-import`, `object.entries`
- [meta] add `--no-save` to link scripts
- [meta] use `prepublishOnly` script for npm 7+
- [dev deps] update `@babel/runtime`, `tape`
18.2.1 / 2020-11-06
==================
- [patch] remove deprecated `jsx-a11y/accessible-emoji` rule (#2322)
- [patch] Fix ignoreNonDOM typo in jsx-a11y/aria-role rule (#2318)
- [patch] Fixed `handle` and `on` ordering in `sort-comp` rule (#2287)
- [deps] update `eslint-plugin-jsx-a11y`, `eslint-plugin-react`
- [deps] update `eslint-config-airbnb-base`, `object.assign`
- [dev deps] update `@babel/runtime`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`
18.2.0 / 2020-06-18
==================
- [new] add `eslint` `v7` (#2240)
- [minor] Allow using `eslint-plugin-react-hooks` v3 and v4 (#2235, #2207)
- [minor] Fix typo in no-multiple-empty-lines rule (#2168)
- [patch] set `explicitSpread` to ignore for `react/jsx-props-no-spreading` (#2237)
- [patch] relax `eslint-plugin-react-hooks` down to v2.3, due to a controversial change in v2.5
- [readme] fix typo (#2194)
- [deps] update `eslint-config-airbnb-base`, `eslint-plugin-jsx-a11y`, `eslint-plugin-import`, `eslint-plugin-react`, `babel-preset-airbnb`, `eslint-find-rules`, `in-publish`, `tape`, `object.entries`
- [tests] fix for eslint 7
18.1.0 / 2020-03-12
==================
- [minor] Support eslint-plugin-react-hooks@2 (#2090)
- [minor] add new disabled rules, update eslint
- [fix] `whitespace`: only set erroring rules to "warn"
- [patch] Remove duplicate `componentDidCatch` (#2108)
- [patch] Add `static-variables` to `sort-comp` rule (#2109)
- [readme] clarify hooks section in readme (#2074)
- [deps] update `eslint`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `eslint-config-airbnb-base`, `eslint-plugin-import`, `object.entries`
- [dev deps] update `@babel/runtime`, `babel-preset-airbnb`, `safe-publish-latest`, `tape`
- [tests] re-enable eslint rule `prefer-destructuring` internally (#2110)
- [tests] fix eslint errors from c66cfc3 (#2112)
18.0.1 / 2019-08-13
==================
- [patch] `react/state-in-constructor`: fix incorrect configuration
18.0.0 / 2019-08-10
==================
- [breaking] add eslint v6, drop eslint v4
- [deps] [breaking] update `eslint-config-airbnb-base`, `eslint-plugin-react`, `eslint-find-rules`, `eslint-plugin-import`
- [breaking] Remove rules/strict from 'extends' (#1962)
- [breaking] set react version to "detect"
- [breaking] disable `label-has-for`; enable `control-has-associated-label`
- [breaking] enable `react/jsx-props-no-spreading`
- [breaking] enable `react/jsx-fragments`
- [minor] enable `react/static-property-placement`
- [minor] enable `react/state-in-constructor`
- [minor] enable `react/jsx-curly-newline`
- [react] Add missing/unsafe lifecycle methods to react/sort-comp rule (#2043)
- [react] add componentDidCatch to lifecycle for react/sort-comp (#2060)
- [react] add `react-hooks` plugin (#2022)
- [dev deps] update babel-related deps to latest
- [tests] only run tests in non-lint per-package travis job
- [tests] use `eclint` instead of `editorconfig-tools`
- [meta] add disabled config for new react and a11y rules
17.1.1 / 2019-07-01
==================
- [patch] Turn off `react/no-multi-comp` (#2006)
- [patch] extend `no-underscore-dangle` to allow for redux dev tools in the main config instead (#1996)
- [meta] add disabled `jsx-fragments` rule
- [deps] update `eslint-config-airbnb-base`, `object.entries`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-jsx-a11y`, `babel-preset-airbnb`, `tape` (#2005, etc)
- [docs] correct JavaScript capitalization (#2046)
- [docs] fix docs for whitespace config (#1914, #1871)
- [readme] Improve eslint config setup instructions for yarn (#2001)
17.1.0 / 2018-08-13
==================
- [new] add eslint v5 support
- [minor] enable `label-has-associated-control` rule
- [patch] re-enabling `jsx-one-expression-per-line` allowing single children, ignore DOM components on `jsx-no-bind`
- [deps] update `eslint`, `eslint-config-airbnb-base`, `eslint-plugin-react`, `eslint-plugin-import`, `safe-publish-latest`, `eslint-plugin-jsx-a11y`, `eslint-find-rules`
- [docs] fix readme typo (#1855)
17.0.0 / 2018-06-21
==================
- [breaking] update `eslint-config-airbnb-base` to v13
- [breaking] enable `no-useless-path-segments` (#1743)
- [breaking] update `eslint-plugin-react` to `v7.6`; update rule configs (#1737)
- [breaking] bump react pragma to v16; update `class-methods-use-this`'s `exceptMethods` to include `componentDidCatch` (#1704)
- [new] Adds config entry point with only whitespace rules enabled (#1749, #1751)
- [patch] set `forbid-foreign-prop-types` to "warn"
- [patch] Add new methods introduced in react@16.3 (#1831)
- [patch] `label-has-for`: Remove redundant component (#1802)
- [patch] Add 'to' as a specialLink to the 'anchor-is-valid' a11y rule (#1648)
- [patch] disable `no-did-mount-set-state`, since its necessary for server-rendering.
- [deps] update `eslint`, `eslint-plugin-react`, `eslint-plugin-import`,
- [dev deps] update `babel-preset-airbnb`, `tape`, `eslint-find-rules`
- [meta] add ES2015-2018 in npm package keywords (#1587)
- [meta] Add licenses to sub packages (#1746)
- [docs] add `npx` shortcut (#1694)
- [docs] Use HTTPS for links to ESLint documentation (#1628)
16.1.0 / 2017-10-16
==================
- [deps] update `eslint-config-airbnb-base`, `eslint` to v4.9
16.0.0 / 2017-10-06
==================
- [breaking] [deps] require `eslint` `v4`, update `eslint-config-airbnb-base`
- [breaking] [deps] Upgrade `eslint-plugin-jsx-a11y` to `v6`; enable more a11y rules (#1482)
- [breaking] enable/add react rules: `react/jsx-curly-brace-presence`, `react/no-typos`, `react/no-unused-state`, `react/no-redundant-should-component-update`, `react/default-props-match-prop-types`
- [new] add `propWrapperFunctions` default settings for `eslint-plugin-react`
- [new] Enable `react/jsx-closing-tag-location` (#1533)
- [deps] update `eslint` v4, `eslint-plugin-react`, `tape`
- [docs] Specify yarn-specific install instructions (#1511)
15.1.0 / 2017-07-24
==================
- [deps] allow eslint v3 or v4 (#1447)
- [deps] update `eslint-plugin-import`, `eslint-config-airbnb-base`
15.0.2 / 2017-07-04
==================
- [fix] jsx should be enabled via parserOptions, not via a root ecmaFeatures
- [deps] update `babel-preset-airbnb`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `tape`
15.0.1 / 2017-05-15
==================
- [fix] set default React version to 15.0 (#1415)
15.0.0 / 2017-05-14
==================
- [breaking] set default React version to 0.15
- [breaking] `update eslint-plugin-jsx-a11y` to v5, enable new rules
- [breaking] `update eslint-plugin-react` to v7, enable new rules
- [minor] enable rules: `jsx-max-props-per-line`, `void-dom-elements-no-children`
- [patch] Turn `ignorePureComponents` option on for react/prefer-stateless-function (#1378, #1398)
- [deps] update `eslint`, `eslint-plugin-react`, `eslint-config-airbnb-base`
14.1.0 / 2017-02-05
==================
- [patch] allow `eslint-plugin-jsx-a11y` to be v3 or v4. Remove `no-marquee` rule temporarily.
- [deps] update `eslint-config-airbnb-base`, `babel-preset-airbnb`, `eslint`
14.0.0 / 2017-01-08
==================
- [breaking] enable `react/no-array-index-key`, `react/require-default-props`
- [breaking] [deps] update `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-config-airbnb-base`
- [breaking] [deps] update `eslint-plugin-jsx-a11y` to v3 (#1166)
- [docs] add note about `install-peerdeps` (#1234)
- [docs] Updated instructions to support non-bash users (#1214)
13.0.0 / 2016-11-06
==================
- [breaking] Enable `import/no-webpack-loader-syntax` rule (#1123)
- [patch] `class-methods-use-this`: exempt React `getChildContext` (#1094)
- [patch] set `react/no-unused-prop-types` skipShapeProps (#1099)
- [deps] [breaking] update `eslint`, `eslint-config-airbnb-base`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-plugin-import`
- [dev deps] update `babel-preset-airbnb`, `eslint`, `eslint-find-rules`, `tape`, `safe-publish-latest`
- [Tests] on `node` `v7`
- [docs] ensure latest version of config is installed (#1121)
12.0.0 / 2016-09-24
==================
- [breaking] Enable react rules: `react/no-unescaped-entities`, `react/no-children-prop`
- [breaking] [deps] update `eslint-config-airbnb-base`
- [patch] disable deprecated and redundant `react/require-extension` rule (#978)
11.2.0 / 2016-09-23
==================
- [new] set `ecmaVersion` to 2017; enable object rest/spread; update `babel-preset-airbnb`
- [deps] update `eslint`, `eslint-config-airbnb-base`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `eslint-plugin-react`, `eslint-find-rules`, `safe-publish-latest`
11.1.0 / 2016-09-11
==================
- [deps] update `eslint-config-airbnb-base`, `eslint`
11.0.0 / 2016-09-08
==================
- [breaking] enable `react` rules: `react/no-danger-with-children`, `react/no-unused-prop-types`, `react/style-prop-object`, `react/forbid-prop-types`, `react/jsx-no-duplicate-props`; set `react/no-danger` to “warn”
- [breaking] enable `jsx-a11y` rules: `jsx-a11y/anchor-has-content`, `jsx-a11y/tabindex-no-positive`, `jsx-a11y/no-static-element-interactions`
- [deps] update `eslint`, `eslint-plugin-react`, `eslint-config-airbnb-base`, `eslint-find-rules`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`
- [patch] set `ignoreCase` to `true` in disabled rules.
- [docs] use “#” in example command rather than version numbers (#984)
10.0.1 / 2016-08-12
==================
- [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-jsx-a11y`, `eslint-plugin-import`, `eslint-config-airbnb-base`
10.0.0 / 2016-08-01
==================
- [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`
- [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`
- [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`
- [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.
- [deps] update `eslint-config-airbnb-base`, `eslint-plugin-react`, `eslint-plugin-import`, `eslint-plugin-jsx-a11y`, `babel-tape-runner`, add `babel-preset-airbnb`. ensure react is `>=` 0.13.0
- [patch] loosen `jsx-pascal-case` rule to allow all caps component names
- [tests] stop testing < node 4
- [tests] use `in-publish` because coffeescript screwed up the prepublish script for everyone
- [tests] Only run `eslint-find-rules` on prepublish, not in tests
- [tests] Even though the base config may not be up to date in the main package, lets `npm link` the base package into the main one for the sake of travis-ci tests
- [docs] update the peer dep install command to dynamically look up the right version numbers when installing peer deps
- add `safe-publish-latest` to `prepublish`
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
@@ -183,42 +436,42 @@
[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
[array-bracket-spacing]: https://eslint.org/docs/rules/array-bracket-spacing
[array-callback-return]: https://eslint.org/docs/rules/array-callback-return
[arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style
[arrow-spacing]: https://eslint.org/docs/rules/arrow-spacing
[computed-property-spacing]: https://eslint.org/docs/rules/computed-property-spacing
[id-length]: https://eslint.org/docs/rules/id-length
[indent]: https://eslint.org/docs/rules/indent
[max-len]: https://eslint.org/docs/rules/max-len
[newline-per-chained-call]: https://eslint.org/docs/rules/newline-per-chained-call
[no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
[no-const-assign]: https://eslint.org/docs/rules/no-const-assign
[no-mixed-spaces-and-tabs]: https://eslint.org/docs/rules/no-mixed-spaces-and-tabs
[no-multiple-empty-lines]: https://eslint.org/docs/rules/no-multiple-empty-lines
[no-new-symbol]: https://eslint.org/docs/rules/no-new-symbol
[no-restricted-imports]: https://eslint.org/docs/rules/no-restricted-imports
[no-self-assign]: https://eslint.org/docs/rules/no-self-assign
[no-undef]: https://eslint.org/docs/rules/no-undef
[no-useless-constructor]: https://eslint.org/docs/rules/no-useless-constructor
[no-whitespace-before-property]: https://eslint.org/docs/rules/no-whitespace-before-property
[object-curly-spacing]: https://eslint.org/docs/rules/object-curly-spacing
[object-shorthand]: https://eslint.org/docs/rules/object-shorthand
[one-var-declaration-per-line]: https://eslint.org/docs/rules/one-var-declaration-per-line
[prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
[prefer-rest-params]: https://eslint.org/docs/rules/prefer-rest-params
[prefer-template]: https://eslint.org/docs/rules/prefer-template
[quote-props]: https://eslint.org/docs/rules/quote-props
[space-before-function-paren]: https://eslint.org/docs/rules/space-before-function-paren
[space-before-keywords]: https://eslint.org/docs/rules/space-before-keywords
[space-in-parens]: https://eslint.org/docs/rules/space-in-parens
[template-curly-spacing]: https://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
[react/jsx-space-before-closing]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/jsx-space-before-closing.md
[react/sort-comp]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/sort-comp.md
[react/display-name]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/display-name.md
[react/jsx-no-bind]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/jsx-no-bind.md
[react/no-is-mounted]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/no-is-mounted.md
[react/prefer-es6-class]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/prefer-es6-class.md
[react/jsx-quotes]: https://github.com/jsx-eslint/eslint-plugin-react/blob/f817e37beddddc84b4788969f07c524fa7f0823b/docs/rules/jsx-quotes.md
[react/prefer-stateless-function]: https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/prefer-stateless-function.md

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2012 Airbnb
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,6 +1,6 @@
# eslint-config-airbnb
[![npm version](https://badge.fury.io/js/eslint-config-airbnb.svg)](http://badge.fury.io/js/eslint-config-airbnb)
[![npm version](https://badge.fury.io/js/eslint-config-airbnb.svg)](https://badge.fury.io/js/eslint-config-airbnb)
This package provides Airbnb's .eslintrc as an extensible shared config.
@@ -10,10 +10,61 @@ 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`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`.
Our default export contains most of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, and `eslint-plugin-jsx-a11y`. Note that it does not enable our React Hooks rules. To enable those, see the [`eslint-config-airbnb/hooks` section](#eslint-config-airbnbhooks).
1. `npm install --save-dev eslint-config-airbnb eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y eslint`
2. add `"extends": "airbnb"` to your .eslintrc
If you don't need React, see [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base).
1. Install the correct versions of each package, which are listed by the command:
```sh
npm info "eslint-config-airbnb@latest" peerDependencies
```
If using **npm 5+**, use this shortcut
```sh
npx install-peerdeps --dev eslint-config-airbnb
```
If using **yarn**, you can also use the shortcut described above if you have npm 5+ installed on your machine, as the command will detect that you are using yarn and will act accordingly.
Otherwise, run `npm info "eslint-config-airbnb@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev <dependency>@<version>` for each listed peer dependency.
If using **npm < 5**, Linux/OSX users can run
```sh
(
export PKG=eslint-config-airbnb;
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)
```
Which produces and runs a command like:
```sh
npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.# eslint-plugin-react-hooks@^#.#.#
```
If using **npm < 5**, Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool.
```sh
npm install -g install-peerdeps
install-peerdeps --dev eslint-config-airbnb
```
The cli will produce and run a command like:
```sh
npm install --save-dev eslint-config-airbnb eslint@^#.#.# eslint-plugin-jsx-a11y@^#.#.# eslint-plugin-import@^#.#.# eslint-plugin-react@^#.#.# eslint-plugin-react-hooks@^#.#.#
```
2. Add `"extends": "airbnb"` to your `.eslintrc`
### eslint-config-airbnb/hooks
This entry point enables the linting rules for React hooks (requires v16.8+). To use, add `"extends": ["airbnb", "airbnb/hooks"]` to your `.eslintrc`.
### eslint-config-airbnb/whitespace
This entry point only errors on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/whitespace.js).
### eslint-config-airbnb/base
@@ -23,8 +74,8 @@ This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.co
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)
See [Airbnb's JavaScript styleguide](https://github.com/airbnb/javascript) and
the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files)
for more information.
## Improving this config

View File

@@ -0,0 +1,6 @@
module.exports = {
extends: [
'./rules/react-hooks.js',
].map(require.resolve),
rules: {}
};

View File

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

View File

@@ -1,13 +1,32 @@
{
"name": "eslint-config-airbnb",
"version": "9.0.0",
"version": "19.0.4",
"description": "Airbnb's ESLint config, following our styleguide",
"main": "index.js",
"exports": {
".": "./index.js",
"./base": "./base.js",
"./hooks": "./hooks.js",
"./legacy": "./legacy.js",
"./whitespace": "./whitespace.js",
"./rules/react": "./rules/react.js",
"./rules/react-a11y": "./rules/react-a11y.js",
"./rules/react-hooks": "./rules/react-hooks.js",
"./package.json": "./package.json"
},
"scripts": {
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
"lint": "eslint .",
"pretests-only": "node ./test/requires",
"tests-only": "babel-tape-runner ./test/test-*.js",
"pretest": "eslint-find-rules --unused",
"test": "npm run --silent lint && npm run --silent tests-only"
"prepublishOnly": "eslint-find-rules --unused && npm test && safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"link:eslint": "cd node_modules/eslint && npm link --production && cd -",
"pretravis": "npm run link:eslint && cd ../eslint-config-airbnb-base && npm link --no-save eslint && npm install && npm link && cd - && npm link --no-save eslint-config-airbnb-base",
"travis": "npm run --silent tests-only",
"posttravis": "npm unlink --no-save eslint-config-airbnb-base eslint >/dev/null &"
},
"repository": {
"type": "git",
@@ -19,7 +38,11 @@
"config",
"airbnb",
"javascript",
"styleguide"
"styleguide",
"es2015",
"es2016",
"es2017",
"es2018"
],
"author": "Jake Teton-Landis (https://twitter.com/@jitl)",
"contributors": [
@@ -43,22 +66,33 @@
},
"homepage": "https://github.com/airbnb/javascript",
"dependencies": {
"eslint-config-airbnb-base": "^3.0.0"
"eslint-config-airbnb-base": "^15.0.0",
"object.entries": "^1.1.6"
},
"devDependencies": {
"babel-tape-runner": "^1.3.1",
"eslint": "^2.9.0",
"eslint-find-rules": "^1.9.2",
"eslint-plugin-import": "^1.7.0",
"eslint-plugin-jsx-a11y": "^1.2.0",
"eslint-plugin-react": "^5.0.1",
"react": "*",
"tape": "^4.5.1"
"@babel/runtime": "^7.21.5",
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-find-rules": "^4.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"in-publish": "^2.0.1",
"react": ">= 0.13.0",
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.3"
},
"peerDependencies": {
"eslint": "^2.9.0",
"eslint-plugin-jsx-a11y": "^1.2.0",
"eslint-plugin-import": "^1.7.0",
"eslint-plugin-react": "^5.0.1"
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0"
},
"engines": {
"node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0"
}
}

View File

@@ -1,5 +0,0 @@
{
"rules": {
"quote-props": 0
}
}

View File

@@ -1,87 +1,266 @@
module.exports = {
'plugins': [
plugins: [
'jsx-a11y',
'react'
],
'ecmaFeatures': {
'jsx': true
parserOptions: {
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,
rules: {
// ensure emoji are accessible
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md
// disabled; rule is deprecated
'jsx-a11y/accessible-emoji': 'off',
// Enforce that all elements that require alternative text have meaningful information
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md
'jsx-a11y/alt-text': ['error', {
elements: ['img', 'object', 'area', 'input[type="image"]'],
img: [],
object: [],
area: [],
'input[type="image"]': [],
}],
// Enforce that anchors have content
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
'jsx-a11y/anchor-has-content': ['error', { components: [] }],
// ensure <a> tags are valid
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md
'jsx-a11y/anchor-is-valid': ['error', {
components: ['Link'],
specialLink: ['to'],
aspects: ['noHref', 'invalidHref', 'preferButton'],
}],
// elements with aria-activedescendant must be tabbable
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
// Enforce all aria-* props are valid.
// TODO: evaluate
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
'jsx-a11y/aria-props': 0,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
'jsx-a11y/aria-props': 'error',
// Enforce ARIA state and property values are valid.
// TODO: evaluate
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
'jsx-a11y/aria-proptypes': 0,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
'jsx-a11y/aria-proptypes': 'error',
// Require ARIA roles to be valid and non-abstract
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md
'jsx-a11y/aria-role': ['error', { ignoreNonDOM: false }],
// Enforce that elements that do not support ARIA roles, states, and
// properties do not have those attributes.
// TODO: evaluate
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
'jsx-a11y/aria-unsupported-elements': 0,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
'jsx-a11y/aria-unsupported-elements': 'error',
// disallow href "#"
// TODO: enable
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md
'jsx-a11y/href-no-hash': 0,
// Ensure the autocomplete attribute is correct and suitable for the form field it is used with
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/29c68596b15c4ff0a40daae6d4a2670e36e37d35/docs/rules/autocomplete-valid.md
'jsx-a11y/autocomplete-valid': ['off', {
inputComponents: [],
}],
// 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,
// require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md
'jsx-a11y/click-events-have-key-events': 'error',
// Enforce that a control (an interactive element) has a text label.
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md
'jsx-a11y/control-has-associated-label': ['error', {
labelAttributes: ['label'],
controlComponents: [],
ignoreElements: [
'audio',
'canvas',
'embed',
'input',
'textarea',
'tr',
'video',
],
ignoreRoles: [
'grid',
'listbox',
'menu',
'menubar',
'radiogroup',
'row',
'tablist',
'toolbar',
'tree',
'treegrid',
],
depth: 5,
}],
// ensure <hX> tags have content and are not aria-hidden
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
'jsx-a11y/heading-has-content': ['error', { components: [''] }],
// require HTML elements to have a "lang" prop
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
'jsx-a11y/html-has-lang': 'error',
// ensure iframe elements have a unique title
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md
'jsx-a11y/iframe-has-title': 'error',
// 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,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md
'jsx-a11y/img-redundant-alt': 'error',
// require that JSX labels use "htmlFor"
// TODO: enable
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
'jsx-a11y/label-has-for': 0,
// Elements with an interactive role and interaction handlers must be focusable
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md
'jsx-a11y/interactive-supports-focus': 'error',
// Enforce that a label tag has a text label and an associated control.
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md
'jsx-a11y/label-has-associated-control': ['error', {
labelComponents: [],
labelAttributes: [],
controlComponents: [],
assert: 'both',
depth: 25
}],
// require HTML element's lang prop to be valid
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
'jsx-a11y/lang': 'error',
// media elements must have captions
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md
'jsx-a11y/media-has-caption': ['error', {
audio: [],
video: [],
track: [],
}],
// require that mouseover/out come with focus/blur, for keyboard-only users
// TODO: enable?
// 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,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
'jsx-a11y/mouse-events-have-key-events': 'error',
// 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,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md
'jsx-a11y/no-access-key': 'error',
// prohibit autoFocus prop
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md
'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }],
// prevent distracting elements, like <marquee> and <blink>
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md
'jsx-a11y/no-distracting-elements': ['error', {
elements: ['marquee', 'blink'],
}],
// WAI-ARIA roles should not be used to convert an interactive element to non-interactive
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md
'jsx-a11y/no-interactive-element-to-noninteractive-role': ['error', {
tr: ['none', 'presentation'],
}],
// A non-interactive element does not support event handlers (mouse and key handlers)
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md
'jsx-a11y/no-noninteractive-element-interactions': ['error', {
handlers: [
'onClick',
'onMouseDown',
'onMouseUp',
'onKeyPress',
'onKeyDown',
'onKeyUp',
]
}],
// WAI-ARIA roles should not be used to convert a non-interactive element to interactive
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md
'jsx-a11y/no-noninteractive-element-to-interactive-role': ['error', {
ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
li: ['menuitem', 'option', 'row', 'tab', 'treeitem'],
table: ['grid'],
td: ['gridcell'],
}],
// Tab key navigation should be limited to elements on the page that can be interacted with.
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md
'jsx-a11y/no-noninteractive-tabindex': ['error', {
tags: [],
roles: ['tabpanel'],
}],
// 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,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md
'jsx-a11y/no-onchange': 'off',
// 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,
// ensure HTML elements do not specify redundant ARIA roles
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md
'jsx-a11y/no-redundant-roles': 'error',
// 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 DOM elements without semantic behavior not have interaction handlers
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md
'jsx-a11y/no-static-element-interactions': ['error', {
handlers: [
'onClick',
'onMouseDown',
'onMouseUp',
'onKeyPress',
'onKeyDown',
'onKeyUp',
]
}],
// Enforce that elements with ARIA roles must have all required attributes
// for that role.
// TODO: evaluate
// 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': 0,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
'jsx-a11y/role-has-required-aria-props': 'error',
// Enforce that elements with explicit or implicit roles defined contain
// only aria-* properties supported by that role.
// TODO: evaluate
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
'jsx-a11y/role-supports-aria-props': 0,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
'jsx-a11y/role-supports-aria-props': 'error',
// only allow <th> to have the "scope" attr
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
'jsx-a11y/scope': 'error',
// 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,
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
'jsx-a11y/tabindex-no-positive': 'error',
// ----------------------------------------------------
// Rules that no longer exist in eslint-plugin-jsx-a11y
// ----------------------------------------------------
// require that JSX labels use "htmlFor"
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
// deprecated: replaced by `label-has-associated-control` rule
'jsx-a11y/label-has-for': ['off', {
components: [],
required: {
every: ['nesting', 'id'],
},
allowChildren: false,
}],
// Ensures anchor text is not ambiguous
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/anchor-ambiguous-text.md
// TODO: semver-major, enable
'jsx-a11y/anchor-ambiguous-text': 'off',
// Enforce that aria-hidden="true" is not set on focusable elements.
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/no-aria-hidden-on-focusable.md
// TODO: semver-major, enable
'jsx-a11y/no-aria-hidden-on-focusable': 'off',
// Enforces using semantic DOM elements over the ARIA role property.
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/93f78856655696a55309440593e0948c6fb96134/docs/rules/prefer-tag-over-role.md
// TODO: semver-major, enable
'jsx-a11y/prefer-tag-over-role': 'off',
},
};

View File

@@ -0,0 +1,21 @@
module.exports = {
plugins: [
'react-hooks',
],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
rules: {
// Enforce Rules of Hooks
// https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
'react-hooks/rules-of-hooks': 'error',
// Verify the list of the dependencies for Hooks like useEffect and similar
// https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
'react-hooks/exhaustive-deps': 'error',
},
};

View File

@@ -1,183 +1,608 @@
const baseStyleRules = require('eslint-config-airbnb-base/rules/style').rules;
const dangleRules = baseStyleRules['no-underscore-dangle'];
module.exports = {
'plugins': [
'react'
plugins: [
'react',
],
'parserOptions': {
'ecmaFeatures': {
'jsx': true,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
'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
// 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
// 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
// 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',
// https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules
rules: {
'no-underscore-dangle': [dangleRules[0], {
...dangleRules[1],
allow: dangleRules[1].allow.concat(['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__']),
}],
// 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
// 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 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,
// 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,
}],
// deprecated in favor of react/jsx-sort-props
'react/jsx-sort-prop-types': 0,
// Enforce props alphabetical sorting
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
'react/jsx-sort-props': [0, {
'ignoreCase': false,
'callbacksLast': false,
}],
// Prevent React to be incorrectly marked as unused
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
'react/jsx-uses-react': [2, { 'pragma': 'React' }],
// 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': [1, { 'react': '0.14.0' }],
// Prevent usage of setState in componentDidMount
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
'react/no-did-mount-set-state': [2, 'allow-in-func'],
// Prevent usage of setState in componentDidUpdate
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
'react/no-did-update-set-state': [2, 'allow-in-func'],
// 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
// 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': 0,
// 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
// 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
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md
'react/require-extension': [0, { 'extensions': ['.jsx'] }],
// 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': [
'static-methods',
'lifecycle',
'/^on.+$/',
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
'everything-else',
'/^render.+$/',
'render'
// Specify whether double or single quotes should be used in JSX attributes
// https://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': ['error', 'prefer-double'],
'class-methods-use-this': ['error', {
exceptMethods: [
'render',
'getInitialState',
'getDefaultProps',
'getChildContext',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount',
'componentDidCatch',
'getSnapshotBeforeUpdate'
],
}],
// Prevent missing parentheses around multilines JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md
'react/wrap-multilines': [2, {
'declaration': true,
'assignment': true,
'return': true
// Prevent missing displayName in a React component definition
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md
'react/display-name': ['off', { ignoreTranspilerName: false }],
// Forbid certain propTypes (any, array, object)
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md
'react/forbid-prop-types': ['error', {
forbid: ['any', 'array', 'object'],
checkContextTypes: true,
checkChildContextTypes: true,
}],
// Forbid certain props on DOM Nodes
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md
'react/forbid-dom-props': ['off', { forbid: [] }],
// Enforce boolean attributes notation in JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
'react/jsx-boolean-value': ['error', 'never', { always: [] }],
// Validate closing bracket location in JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
// Validate closing tag location in JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md
'react/jsx-closing-tag-location': 'error',
// Enforce or disallow spaces inside of curly braces in JSX attributes
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
// Enforce event handler naming conventions in JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
'react/jsx-handler-names': ['off', {
eventHandlerPrefix: 'handle',
eventHandlerPropPrefix: 'on',
}],
// Validate props indentation in JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
'react/jsx-indent-props': ['error', 2],
// Validate JSX has key prop when in array or iterator
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
// Turned off because it has too many false positives
'react/jsx-key': 'off',
// Limit maximum of props on a single line in JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }],
// Prevent usage of .bind() in JSX props
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
'react/jsx-no-bind': ['error', {
ignoreRefs: true,
allowArrowFunctions: true,
allowFunctions: false,
allowBind: false,
ignoreDOMComponents: true,
}],
// Prevent duplicate props in JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
// Prevent usage of unwrapped JSX strings
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
'react/jsx-no-literals': ['off', { noStrings: true }],
// Disallow undeclared variables in JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
'react/jsx-no-undef': 'error',
// Enforce PascalCase for user-defined JSX components
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
'react/jsx-pascal-case': ['error', {
allowAllCaps: true,
ignore: [],
}],
// Enforce propTypes declarations alphabetical sorting
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md
'react/sort-prop-types': ['off', {
ignoreCase: true,
callbacksLast: false,
requiredFirst: false,
sortShapeProp: true,
}],
// Deprecated in favor of react/jsx-sort-props
'react/jsx-sort-prop-types': 'off',
// Enforce props alphabetical sorting
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
'react/jsx-sort-props': ['off', {
ignoreCase: true,
callbacksLast: false,
shorthandFirst: false,
shorthandLast: false,
noSortAlphabetically: false,
reservedFirst: true,
}],
// Enforce defaultProps declarations alphabetical sorting
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md
'react/jsx-sort-default-props': ['off', {
ignoreCase: true,
}],
// Prevent React to be incorrectly marked as unused
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
'react/jsx-uses-react': ['error'],
// Prevent variables used in JSX to be incorrectly marked as unused
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
'react/jsx-uses-vars': 'error',
// Prevent usage of dangerous JSX properties
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger.md
'react/no-danger': 'warn',
// Prevent usage of deprecated methods
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
'react/no-deprecated': ['error'],
// Prevent usage of setState in componentDidMount
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
// this is necessary for server-rendering
'react/no-did-mount-set-state': 'off',
// Prevent usage of setState in componentDidUpdate
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
'react/no-did-update-set-state': 'error',
// Prevent usage of setState in componentWillUpdate
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md
'react/no-will-update-set-state': 'error',
// Prevent direct mutation of this.state
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
'react/no-direct-mutation-state': 'off',
// Prevent usage of isMounted
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
'react/no-is-mounted': 'error',
// Prevent multiple component definition per file
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
'react/no-multi-comp': 'off',
// Prevent usage of setState
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
'react/no-set-state': 'off',
// Prevent using string references
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
'react/no-string-refs': 'error',
// Prevent usage of unknown DOM property
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
'react/no-unknown-property': 'error',
// Require ES6 class declarations over React.createClass
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md
'react/prefer-es6-class': ['error', 'always'],
// Require stateless functions when not using lifecycle methods, setState or ref
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
// Prevent missing props validation in a React component definition
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md
'react/prop-types': ['error', {
ignore: [],
customValidators: [],
skipUndeclared: false
}],
// Prevent missing React when using JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
'react/react-in-jsx-scope': 'error',
// Require render() methods to return something
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
'react/require-render-return': 'error',
// Prevent extra closing tags for components without children
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
'react/self-closing-comp': 'error',
// Enforce component methods order
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md
'react/sort-comp': ['error', {
order: [
'static-variables',
'static-methods',
'instance-variables',
'lifecycle',
'/^handle.+$/',
'/^on.+$/',
'getters',
'setters',
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
'instance-methods',
'everything-else',
'rendering',
],
groups: {
lifecycle: [
'displayName',
'propTypes',
'contextTypes',
'childContextTypes',
'mixins',
'statics',
'defaultProps',
'constructor',
'getDefaultProps',
'getInitialState',
'state',
'getChildContext',
'getDerivedStateFromProps',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'getSnapshotBeforeUpdate',
'componentDidUpdate',
'componentDidCatch',
'componentWillUnmount'
],
rendering: [
'/^render.+$/',
'render'
],
},
}],
// Prevent missing parentheses around multilines JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-wrap-multilines.md
'react/jsx-wrap-multilines': ['error', {
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
arrow: 'parens-new-line',
condition: 'parens-new-line',
logical: 'parens-new-line',
prop: 'parens-new-line',
}],
// 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],
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
// Enforce spacing around jsx equals signs
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
'react/jsx-equals-spacing': ['error', 'never'],
// Enforce JSX indentation
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
'react/jsx-indent': ['error', 2],
// Disallow target="_blank" on links
// https://github.com/jsx-eslint/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md
'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }],
// only .jsx files may have JSX
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
'react/jsx-filename-extension': ['error', { extensions: ['.jsx'] }],
// prevent accidental JS comments from being injected into JSX as text
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
'react/jsx-no-comment-textnodes': 'error',
// disallow using React.render/ReactDOM.render's return value
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
'react/no-render-return-value': 'error',
// require a shouldComponentUpdate method, or PureRenderMixin
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
'react/require-optimization': ['off', { allowDecorators: [] }],
// warn against using findDOMNode()
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
'react/no-find-dom-node': 'error',
// Forbid certain props on Components
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md
'react/forbid-component-props': ['off', { forbid: [] }],
// Forbid certain elements
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md
'react/forbid-elements': ['off', { forbid: [], }],
// Prevent problem with children and props.dangerouslySetInnerHTML
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md
'react/no-danger-with-children': 'error',
// Prevent unused propType definitions
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md
'react/no-unused-prop-types': ['error', {
customValidators: [
],
skipShapeProps: true,
}],
// Require style prop value be an object or var
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md
'react/style-prop-object': 'error',
// Prevent invalid characters from appearing in markup
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md
'react/no-unescaped-entities': 'error',
// Prevent passing of children as props
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
'react/no-children-prop': 'error',
// Validate whitespace in and around the JSX opening and closing brackets
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-tag-spacing.md
'react/jsx-tag-spacing': ['error', {
closingSlash: 'never',
beforeSelfClosing: 'always',
afterOpening: 'never',
beforeClosing: 'never',
}],
// Enforce spaces before the closing bracket of self-closing JSX elements
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md
// Deprecated in favor of jsx-tag-spacing
'react/jsx-space-before-closing': ['off', 'always'],
// Prevent usage of Array index in keys
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
'react/no-array-index-key': 'error',
// Enforce a defaultProps definition for every prop that is not a required prop
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md
'react/require-default-props': ['error', {
forbidDefaultForRequired: true,
}],
// Forbids using non-exported propTypes
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md
// this is intentionally set to "warn". it would be "error",
// but it's only critical if you're stripping propTypes in production.
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
// Prevent void DOM elements from receiving children
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md
'react/void-dom-elements-no-children': 'error',
// Enforce all defaultProps have a corresponding non-required PropType
// https://github.com/jsx-eslint/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/default-props-match-prop-types.md
'react/default-props-match-prop-types': ['error', { allowRequiredDefaults: false }],
// Prevent usage of shouldComponentUpdate when extending React.PureComponent
// https://github.com/jsx-eslint/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md
'react/no-redundant-should-component-update': 'error',
// Prevent unused state values
// https://github.com/jsx-eslint/eslint-plugin-react/pull/1103/
'react/no-unused-state': 'error',
// Enforces consistent naming for boolean props
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/boolean-prop-naming.md
'react/boolean-prop-naming': ['off', {
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
message: '',
}],
// Prevents common casing typos
// https://github.com/jsx-eslint/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md
'react/no-typos': 'error',
// Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
// One JSX Element Per Line
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md
'react/jsx-one-expression-per-line': ['error', { allow: 'single-child' }],
// Enforce consistent usage of destructuring assignment of props, state, and context
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md
'react/destructuring-assignment': ['error', 'always'],
// Prevent using this.state within a this.setState
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md
'react/no-access-state-in-setstate': 'error',
// Prevent usage of button elements without an explicit type attribute
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/button-has-type.md
'react/button-has-type': ['error', {
button: true,
submit: true,
reset: false,
}],
// Ensures inline tags are not rendered without spaces between them
'react/jsx-child-element-spacing': 'off',
// Prevent this from being used in stateless functional components
// https://github.com/jsx-eslint/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md
'react/no-this-in-sfc': 'error',
// Validate JSX maximum depth
// https://github.com/jsx-eslint/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md
'react/jsx-max-depth': 'off',
// Disallow multiple spaces between inline JSX props
// https://github.com/jsx-eslint/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md
'react/jsx-props-no-multi-spaces': 'error',
// Prevent usage of UNSAFE_ methods
// https://github.com/jsx-eslint/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md
'react/no-unsafe': 'off',
// Enforce shorthand or standard form for React fragments
// https://github.com/jsx-eslint/eslint-plugin-react/blob/bc976b837abeab1dffd90ac6168b746a83fc83cc/docs/rules/jsx-fragments.md
'react/jsx-fragments': ['error', 'syntax'],
// Enforce linebreaks in curly braces in JSX attributes and expressions.
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md
'react/jsx-curly-newline': ['error', {
multiline: 'consistent',
singleline: 'consistent',
}],
// Enforce state initialization style
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md
// TODO: set to "never" once babel-preset-airbnb supports public class fields
'react/state-in-constructor': ['error', 'always'],
// Enforces where React component static properties should be positioned
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md
// TODO: set to "static public field" once babel-preset-airbnb supports public class fields
'react/static-property-placement': ['error', 'property assignment'],
// Disallow JSX props spreading
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md
'react/jsx-props-no-spreading': ['error', {
html: 'enforce',
custom: 'enforce',
explicitSpread: 'ignore',
exceptions: [],
}],
// Enforce that props are read-only
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md
'react/prefer-read-only-props': 'off',
// Prevent usage of `javascript:` URLs
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md
'react/jsx-no-script-url': ['error', [
{
name: 'Link',
props: ['to'],
},
]],
// Disallow unnecessary fragments
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
'react/jsx-no-useless-fragment': 'error',
// Prevent adjacent inline elements not separated by whitespace
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md
// TODO: enable? semver-major
'react/no-adjacent-inline-elements': 'off',
// Enforce a specific function type for function components
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
'react/function-component-definition': ['error', {
namedComponents: ['function-declaration', 'function-expression'],
unnamedComponents: 'function-expression',
}],
// Enforce a new line after jsx elements and expressions
// https://github.com/jsx-eslint/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-newline.md
'react/jsx-newline': 'off',
// Prevent react contexts from taking non-stable values
// https://github.com/jsx-eslint/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-no-constructed-context-values.md
'react/jsx-no-constructed-context-values': 'error',
// Prevent creating unstable components inside components
// https://github.com/jsx-eslint/eslint-plugin-react/blob/c2a790a3472eea0f6de984bdc3ee2a62197417fb/docs/rules/no-unstable-nested-components.md
'react/no-unstable-nested-components': 'error',
// Enforce that namespaces are not used in React elements
// https://github.com/jsx-eslint/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/no-namespace.md
'react/no-namespace': 'error',
// Prefer exact proptype definitions
// https://github.com/jsx-eslint/eslint-plugin-react/blob/8785c169c25b09b33c95655bf508cf46263bc53f/docs/rules/prefer-exact-props.md
'react/prefer-exact-props': 'error',
// Lifecycle methods should be methods on the prototype, not class fields
// https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-arrow-function-lifecycle.md
'react/no-arrow-function-lifecycle': 'error',
// Prevent usage of invalid attributes
// https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-invalid-html-attribute.md
'react/no-invalid-html-attribute': 'error',
// Prevent declaring unused methods of component class
// https://github.com/jsx-eslint/eslint-plugin-react/blob/21e01b61af7a38fc86d94f27eb66cda8054582ed/docs/rules/no-unused-class-component-methods.md
'react/no-unused-class-component-methods': 'error',
// Ensure destructuring and symmetric naming of useState hook value and setter variables
// https://github.com/jsx-eslint/eslint-plugin-react/blob/c8833f301314dab3e79ef7ac4cf863e4d5fa0019/docs/rules/hook-use-state.md
// TODO: semver-major, enable
'react/hook-use-state': 'off',
// Enforce sandbox attribute on iframe elements
// https://github.com/jsx-eslint/eslint-plugin-react/blob/c8833f301314dab3e79ef7ac4cf863e4d5fa0019/docs/rules/iframe-missing-sandbox.md
// TODO: semver-major, enable
'react/iframe-missing-sandbox': 'off',
// Prevent problematic leaked values from being rendered
// https://github.com/jsx-eslint/eslint-plugin-react/blob/c42b624d0fb9ad647583a775ab9751091eec066f/docs/rules/jsx-no-leaked-render.md
// TODO: semver-major, enable
'react/jsx-no-leaked-render': 'off',
// https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/no-object-type-as-default-prop.md
// https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/no-object-type-as-default-prop.md
// TODO: semver-major, enable
'react/no-object-type-as-default-prop': 'off',
// https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/sort-default-props.md
// https://github.com/jsx-eslint/eslint-plugin-react/blob/66b58dd4864678eb869a7bf434c72ff7ac530eb1/docs/rules/sort-default-props.md
// TODO: semver-major, enable?
'react/sort-default-props': ['off', {
ignoreCase: false
}],
},
'settings': {
settings: {
'import/resolver': {
'node': {
'extensions': ['.js', '.jsx', '.json']
node: {
extensions: ['.js', '.jsx', '.json']
}
},
'react': {
'pragma': 'React',
'version': '0.14'
react: {
pragma: 'React',
version: 'detect',
},
propWrapperFunctions: [
'forbidExtraProps', // https://www.npmjs.com/package/airbnb-prop-types
'exact', // https://www.npmjs.com/package/prop-types-exact
'Object.freeze', // https://tc39.github.io/ecma262/#sec-object.freeze
],
}
};

View File

@@ -1,8 +1,8 @@
{
"rules": {
// disabled because I find it tedious to write tests while following this
// rule
// 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"]}]
}

View File

@@ -0,0 +1,15 @@
/* eslint strict: 0, global-require: 0 */
'use strict';
const test = require('tape');
test('all entry points parse', (t) => {
t.doesNotThrow(() => require('..'), 'index does not throw');
t.doesNotThrow(() => require('../base'), 'base does not throw');
t.doesNotThrow(() => require('../legacy'), 'legacy does not throw');
t.doesNotThrow(() => require('../whitespace'), 'whitespace does not throw');
t.doesNotThrow(() => require('../hooks'), 'hooks does not throw');
t.end();
});

View File

@@ -6,28 +6,30 @@ const base = require('../base');
const files = { base };
fs.readdirSync(path.join(__dirname, '../rules')).forEach(name => {
const rulesDir = path.join(__dirname, '../rules');
fs.readdirSync(rulesDir).forEach((name) => {
if (name === 'react.js' || name === 'react-a11y.js') {
return;
}
files[name] = require(`../rules/${name}`); // eslint-disable-line global-require
// eslint-disable-next-line import/no-dynamic-require
files[name] = require(path.join(rulesDir, name)); // eslint-disable-line global-require
});
Object.keys(files).forEach(name => {
Object.keys(files).forEach((name) => {
const config = files[name];
test(`${name}: does not reference react`, t => {
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;
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);
.filter((ruleId) => ruleId.indexOf('react/') === 0);
t.deepEquals(reactRuleIds, [], 'there are no react/ rules');
});
});

View File

@@ -1,46 +1,52 @@
import test from 'tape';
import { CLIEngine } from 'eslint';
import eslintrc from '../';
import { CLIEngine, ESLint } from 'eslint';
import eslintrc from '..';
import reactRules from '../rules/react';
import reactA11yRules from '../rules/react-a11y';
const cli = new CLIEngine({
const rules = {
// It is okay to import devDependencies in tests.
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
// this doesn't matter for tests
'lines-between-class-members': 0,
// otherwise we need some junk in our fixture code
'react/no-unused-class-component-methods': 0,
};
const cli = new (CLIEngine || ESLint)({
useEslintrc: false,
baseConfig: eslintrc,
// This rule fails when executing on text.
rules: { indent: 0 },
...(CLIEngine ? { rules } : { overrideConfig: { rules } }),
});
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
const linter = cli.executeOnText(text);
return linter.results[0];
async function lint(text) {
// @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles
// @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeontext
const linter = CLIEngine ? cli.executeOnText(text) : await cli.lintText(text);
return (CLIEngine ? linter.results : linter)[0];
}
function wrapComponent(body) {
return `
return `\
import React from 'react';
export default class MyComponent extends React.Component {
/* eslint no-empty-function: 0 */
${body}
}
/* eslint no-empty-function: 0, class-methods-use-this: 0 */
${body}}
`;
}
test('validate react prop order', (t) => {
test('validate react methods order', (t) => {
t.test('make sure our eslintrc has React and JSX linting dependencies', (t) => {
t.plan(2);
t.deepEqual(reactRules.plugins, ['react']);
t.deepEqual(reactA11yRules.plugins, ['jsx-a11y', 'react']);
});
t.test('passes a good component', (t) => {
t.plan(3);
const result = lint(wrapComponent(`
componentWillMount() {}
t.test('passes a good component', async (t) => {
const result = await lint(wrapComponent(`
componentDidMount() {}
handleSubmit() {}
onButtonAClick() {}
setFoo() {}
getFoo() {}
setBar() {}
@@ -50,15 +56,13 @@ test('validate react prop order', (t) => {
`));
t.notOk(result.warningCount, 'no warnings');
t.notOk(result.errorCount, 'no errors');
t.deepEquals(result.messages, [], 'no messages in results');
t.notOk(result.errorCount, 'no errors');
});
t.test('order: when random method is first', t => {
t.plan(2);
const result = lint(wrapComponent(`
t.test('order: when random method is first', async (t) => {
const result = await lint(wrapComponent(`
someMethod() {}
componentWillMount() {}
componentDidMount() {}
setFoo() {}
getFoo() {}
@@ -68,13 +72,11 @@ test('validate react prop order', (t) => {
`));
t.ok(result.errorCount, 'fails');
t.equal(result.messages[0].ruleId, 'react/sort-comp', 'fails due to sort');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});
t.test('order: when random method after lifecycle methods', t => {
t.plan(2);
const result = lint(wrapComponent(`
componentWillMount() {}
t.test('order: when random method after lifecycle methods', async (t) => {
const result = await lint(wrapComponent(`
componentDidMount() {}
someMethod() {}
setFoo() {}
@@ -85,6 +87,46 @@ test('validate react prop order', (t) => {
`));
t.ok(result.errorCount, 'fails');
t.equal(result.messages[0].ruleId, 'react/sort-comp', 'fails due to sort');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});
t.test('order: when handler method with `handle` prefix after method with `on` prefix', async (t) => {
const result = await lint(wrapComponent(`
componentDidMount() {}
onButtonAClick() {}
handleSubmit() {}
setFoo() {}
getFoo() {}
render() { return <div />; }
`));
t.ok(result.errorCount, 'fails');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});
t.test('order: when lifecycle methods after event handler methods', async (t) => {
const result = await lint(wrapComponent(`
handleSubmit() {}
componentDidMount() {}
setFoo() {}
getFoo() {}
render() { return <div />; }
`));
t.ok(result.errorCount, 'fails');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});
t.test('order: when event handler methods after getters and setters', async (t) => {
const result = await lint(wrapComponent(`
componentDidMount() {}
setFoo() {}
getFoo() {}
handleSubmit() {}
render() { return <div />; }
`));
t.ok(result.errorCount, 'fails');
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
});
});

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env node
const entries = require('object.entries');
const { ESLint } = require('eslint');
const baseConfig = require('.');
const whitespaceRules = require('./whitespaceRules');
const severities = ['off', 'warn', 'error'];
function getSeverity(ruleConfig) {
if (Array.isArray(ruleConfig)) {
return getSeverity(ruleConfig[0]);
}
if (typeof ruleConfig === 'number') {
return severities[ruleConfig];
}
return ruleConfig;
}
async function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = { ...config };
const cli = new ESLint({
useEslintrc: false,
baseConfig: config
});
const baseRules = (await cli.calculateConfigForFile(require.resolve('./'))).rules;
entries(baseRules).forEach((rule) => {
const ruleName = rule[0];
const ruleConfig = rule[1];
const severity = getSeverity(ruleConfig);
if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') {
if (Array.isArray(ruleConfig)) {
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
} else if (typeof ruleConfig === 'number') {
errorsOnly.rules[ruleName] = 1;
} else {
errorsOnly.rules[ruleName] = 'warn';
}
}
});
return errorsOnly;
}
onlyErrorOnRules(whitespaceRules, baseConfig).then((config) => console.log(JSON.stringify(config)));

View File

@@ -0,0 +1,54 @@
/* eslint global-require: 0 */
const { CLIEngine } = require('eslint');
if (CLIEngine) {
/* eslint no-inner-declarations: 0 */
const entries = require('object.entries');
const whitespaceRules = require('./whitespaceRules');
const baseConfig = require('.');
const severities = ['off', 'warn', 'error'];
function getSeverity(ruleConfig) {
if (Array.isArray(ruleConfig)) {
return getSeverity(ruleConfig[0]);
}
if (typeof ruleConfig === 'number') {
return severities[ruleConfig];
}
return ruleConfig;
}
function onlyErrorOnRules(rulesToError, config) {
const errorsOnly = { ...config };
const cli = new CLIEngine({ baseConfig: config, useEslintrc: false });
const baseRules = cli.getConfigForFile(require.resolve('./')).rules;
entries(baseRules).forEach((rule) => {
const ruleName = rule[0];
const ruleConfig = rule[1];
const severity = getSeverity(ruleConfig);
if (rulesToError.indexOf(ruleName) === -1 && severity === 'error') {
if (Array.isArray(ruleConfig)) {
errorsOnly.rules[ruleName] = ['warn'].concat(ruleConfig.slice(1));
} else if (typeof ruleConfig === 'number') {
errorsOnly.rules[ruleName] = 1;
} else {
errorsOnly.rules[ruleName] = 'warn';
}
}
});
return errorsOnly;
}
module.exports = onlyErrorOnRules(whitespaceRules, baseConfig);
} else {
const path = require('path');
const { execSync } = require('child_process');
module.exports = JSON.parse(String(execSync(path.join(__dirname, 'whitespace-async.js'))));
}

View File

@@ -0,0 +1,64 @@
module.exports = [
'array-bracket-newline',
'array-bracket-spacing',
'array-element-newline',
'arrow-spacing',
'block-spacing',
'comma-spacing',
'computed-property-spacing',
'dot-location',
'eol-last',
'func-call-spacing',
'function-paren-newline',
'generator-star-spacing',
'implicit-arrow-linebreak',
'indent',
'key-spacing',
'keyword-spacing',
'line-comment-position',
'linebreak-style',
'multiline-ternary',
'newline-per-chained-call',
'no-irregular-whitespace',
'no-mixed-spaces-and-tabs',
'no-multi-spaces',
'no-regex-spaces',
'no-spaced-func',
'no-trailing-spaces',
'no-whitespace-before-property',
'nonblock-statement-body-position',
'object-curly-newline',
'object-curly-spacing',
'object-property-newline',
'one-var-declaration-per-line',
'operator-linebreak',
'padded-blocks',
'padding-line-between-statements',
'rest-spread-spacing',
'semi-spacing',
'semi-style',
'space-before-blocks',
'space-before-function-paren',
'space-in-parens',
'space-infix-ops',
'space-unary-ops',
'spaced-comment',
'switch-colon-spacing',
'template-tag-spacing',
'import/newline-after-import',
// eslint-plugin-react rules
'react/jsx-child-element-spacing',
'react/jsx-closing-bracket-location',
'react/jsx-closing-tag-location',
'react/jsx-curly-spacing',
'react/jsx-equals-spacing',
'react/jsx-first-prop-newline',
'react/jsx-indent',
'react/jsx-indent-props',
'react/jsx-max-props-per-line',
'react/jsx-one-expression-per-line',
'react/jsx-space-before-closing',
'react/jsx-tag-spacing',
'react/jsx-wrap-multilines',
];

View File

@@ -2,16 +2,20 @@
*A mostly reasonable approach to React and JSX*
This style guide is mostly based on the standards that are currently prevalent in JavaScript, although some conventions (i.e async/await or static class fields) may still be included or prohibited on a case-by-case basis. Currently, anything prior to stage 3 is not included nor recommended in this guide.
## Table of Contents
1. [Basic Rules](#basic-rules)
1. [Class vs `React.createClass` vs stateless](#class-vs-reactcreateclass-vs-stateless)
1. [Mixins](#mixins)
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)
@@ -21,13 +25,14 @@
## 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).
- 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/jsx-eslint/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.
- Do not use `React.createElement` unless youre initializing the app from a file that is not JSX.
- [`react/forbid-prop-types`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md) will allow `arrays` and `objects` only if it is explicitly noted what `array` and `object` contains, using `arrayOf`, `objectOf`, or `shape`.
## Class vs `React.createClass` vs stateless
- 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)
- If you have internal state and/or refs, prefer `class extends React.Component` over `React.createClass`. eslint: [`react/prefer-es6-class`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md) [`react/prefer-stateless-function`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md)
```jsx
// bad
@@ -47,7 +52,7 @@
}
```
And if you don't have state or refs, prefer normal functions (not arrow functions) over classes:
And if you dont have state or refs, prefer normal functions (not arrow functions) over classes:
```jsx
// bad
@@ -68,11 +73,17 @@
}
```
## Mixins
- [Do not use mixins](https://facebook.github.io/react/blog/2016/07/13/mixins-considered-harmful.html).
> Why? Mixins introduce implicit dependencies, cause name clashes, and cause snowballing complexity. Most use cases for mixins can be accomplished in better ways via components, higher-order components, or utility modules.
## Naming
- **Extensions**: Use `.jsx` extension for React components.
- **Extensions**: Use `.jsx` extension for React components. eslint: [`react/jsx-filename-extension`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md)
- **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.jsx`.
- **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)
- **Reference Naming**: Use PascalCase for React components and camelCase for their instances. eslint: [`react/jsx-pascal-case`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md)
```jsx
// bad
@@ -101,6 +112,48 @@
import Footer from './Footer';
```
- **Higher-order Component Naming**: Use a composite of the higher-order components name and the passed-in components 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 components `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;
}
```
- **Props Naming**: Avoid using DOM component prop names for different purposes.
> Why? People expect props like `style` and `className` to mean one specific thing. Varying this API for a subset of your app makes the code less readable and less maintainable, and may cause bugs.
```jsx
// bad
<MyComponent style="fancy" />
// bad
<MyComponent className="fancy" />
// good
<MyComponent variant="fancy" />
```
## Declaration
- Do not use `displayName` for naming components. Instead, name the component by reference.
@@ -119,7 +172,7 @@
## Alignment
- 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)
- Follow these alignment styles for JSX syntax. eslint: [`react/jsx-closing-bracket-location`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md) [`react/jsx-closing-tag-location`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md)
```jsx
// bad
@@ -142,14 +195,53 @@
>
<Quux />
</Foo>
// bad
{showButton &&
<Button />
}
// bad
{
showButton &&
<Button />
}
// good
{showButton && (
<Button />
)}
// good
{showButton && <Button />}
// good
{someReallyLongConditional
&& anotherLongConditional
&& (
<Foo
superLongParam="bar"
anotherSuperLongParam="baz"
/>
)
}
// good
{someConditional ? (
<Foo />
) : (
<Foo
superLongParam="bar"
anotherSuperLongParam="baz"
/>
)}
```
## Quotes
- Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS. eslint: [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes)
- Always use double quotes (`"`) for JSX attributes, but single quotes (`'`) for all other JS. eslint: [`jsx-quotes`](https://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 conjunctions like `"don't"` easier to type.
> Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention.
> Why? Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention.
```jsx
// bad
@@ -167,7 +259,7 @@
## Spacing
- Always include a single space in your self-closing tag.
- Always include a single space in your self-closing tag. eslint: [`no-multi-spaces`](https://eslint.org/docs/rules/no-multi-spaces), [`react/jsx-tag-spacing`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md)
```jsx
// bad
@@ -184,7 +276,7 @@
<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)
- Do not pad JSX curly braces with spaces. eslint: [`react/jsx-curly-spacing`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md)
```jsx
// bad
@@ -196,7 +288,7 @@
## Props
- Always use camelCase for prop names.
- Always use camelCase for prop names, or PascalCase if the prop value is a React component.
```jsx
// bad
@@ -209,10 +301,11 @@
<Foo
userName="hello"
phoneNumber={12345678}
Component={SomeComponent}
/>
```
- 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)
- Omit the value of the prop when it is explicitly `true`. eslint: [`react/jsx-boolean-value`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md)
```jsx
// bad
@@ -224,9 +317,12 @@
<Foo
hidden
/>
// 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)
- 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/alt-text`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md)
```jsx
// bad
@@ -242,9 +338,9 @@
<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)
- Do not use words like "image", "photo", or "picture" in `<img>` `alt` props. eslint: [`jsx-a11y/img-redundant-alt`](https://github.com/jsx-eslint/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.
> Why? Screenreaders already announce `img` elements as images, so there is no need to include this information in the alt text.
```jsx
// bad
@@ -254,7 +350,7 @@
<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)
- Use only valid, non-abstract [ARIA roles](https://www.w3.org/TR/wai-aria/#usage_intro). eslint: [`jsx-a11y/aria-role`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md)
```jsx
// bad - not an ARIA role
@@ -267,7 +363,7 @@
<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)
- Do not use `accessKey` on elements. eslint: [`jsx-a11y/no-access-key`](https://github.com/jsx-eslint/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.
@@ -279,14 +375,136 @@
<div />
```
- Avoid using an array index as `key` prop, prefer a stable ID. eslint: [`react/no-array-index-key`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md)
> Why? Not using a stable ID [is an anti-pattern](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318) because it can negatively impact performance and cause issues with component state.
We dont recommend using indexes for keys if the order of items may change.
```jsx
// bad
{todos.map((todo, index) =>
<Todo
{...todo}
key={index}
/>
)}
// good
{todos.map(todo => (
<Todo
{...todo}
key={todo.id}
/>
))}
```
- Always define explicit defaultProps for all non-required props.
> Why? propTypes are a form of documentation, and providing defaultProps means the reader of your code doesnt have to assume as much. In addition, it can mean that your code can omit certain type checks.
```jsx
// bad
function SFC({ foo, bar, children }) {
return <div>{foo}{bar}{children}</div>;
}
SFC.propTypes = {
foo: PropTypes.number.isRequired,
bar: PropTypes.string,
children: PropTypes.node,
};
// good
function SFC({ foo, bar, children }) {
return <div>{foo}{bar}{children}</div>;
}
SFC.propTypes = {
foo: PropTypes.number.isRequired,
bar: PropTypes.string,
children: PropTypes.node,
};
SFC.defaultProps = {
bar: '',
children: null,
};
```
- Use spread props sparingly.
> Why? Otherwise youre more likely to pass unnecessary props down to components. And for React v15.6.1 and older, you could [pass invalid HTML attributes to the DOM](https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html).
Exceptions:
- HOCs that proxy down props and hoist propTypes
```jsx
function HOC(WrappedComponent) {
return class Proxy extends React.Component {
Proxy.propTypes = {
text: PropTypes.string,
isLoading: PropTypes.bool
};
render() {
return <WrappedComponent {...this.props} />
}
}
}
```
- Spreading objects with known, explicit props. This can be particularly useful when testing React components with Mochas beforeEach construct.
```jsx
export default function Foo {
const props = {
text: '',
isPublished: false
}
return (<div {...props} />);
}
```
Notes for use:
Filter out unnecessary props when possible. Also, use [prop-types-exact](https://www.npmjs.com/package/prop-types-exact) to help prevent bugs.
```jsx
// bad
render() {
const { irrelevantProp, ...relevantProps } = this.props;
return <WrappedComponent {...this.props} />
}
// good
render() {
const { irrelevantProp, ...relevantProps } = this.props;
return <WrappedComponent {...relevantProps} />
}
```
## Refs
- Always use ref callbacks. eslint: [`react/no-string-refs`](https://github.com/jsx-eslint/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. eslint: [`react/wrap-multilines`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md)
- Wrap JSX tags in parentheses when they span more than one line. eslint: [`react/jsx-wrap-multilines`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md)
```jsx
// bad
render() {
return <MyComponent className="long body" foo="bar">
return <MyComponent variant="long body" foo="bar">
<MyChild />
</MyComponent>;
}
@@ -294,7 +512,7 @@
// good
render() {
return (
<MyComponent className="long body" foo="bar">
<MyComponent variant="long body" foo="bar">
<MyChild />
</MyComponent>
);
@@ -309,17 +527,17 @@
## Tags
- 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)
- Always self-close tags that have no children. eslint: [`react/self-closing-comp`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md)
```jsx
// bad
<Foo className="stuff"></Foo>
<Foo variant="stuff"></Foo>
// good
<Foo className="stuff" />
<Foo variant="stuff" />
```
- 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)
- If your component has multiline properties, close its tag on a new line. eslint: [`react/jsx-closing-bracket-location`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md)
```jsx
// bad
@@ -336,7 +554,7 @@
## Methods
- Use arrow functions to close over local variables.
- Use arrow functions to close over local variables. It is handy when you need to pass additional data to an event handler. Although, make sure they [do not massively hurt performance](https://www.bignerdranch.com/blog/choosing-the-best-approach-for-react-event-handlers/), in particular when passed to custom components that might be PureComponents, because they will trigger a possibly needless rerender every time.
```jsx
function ItemList(props) {
@@ -345,7 +563,7 @@
{props.items.map((item, index) => (
<Item
key={item.key}
onClick={() => doSomethingWith(item.name, index)}
onClick={(event) => { doSomethingWith(event, item.name, index); }}
/>
))}
</ul>
@@ -353,9 +571,9 @@
}
```
- 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)
- Bind event handlers for the render method in the constructor. eslint: [`react/jsx-no-bind`](https://github.com/jsx-eslint/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.
> Why? A bind call in the render path creates a brand new function on every single render. Do not use arrow functions in class fields, because it makes them [challenging to test and debug, and can negatively impact performance](https://medium.com/@charpeni/arrow-functions-in-class-properties-might-not-be-as-great-as-we-think-3b3551c440b1), and because conceptually, class fields are for data, not logic.
```jsx
// bad
@@ -365,7 +583,18 @@
}
render() {
return <div onClick={this.onClickDiv.bind(this)} />
return <div onClick={this.onClickDiv.bind(this)} />;
}
}
// very bad
class extends React.Component {
onClickDiv = () => {
// do stuff
}
render() {
return <div onClick={this.onClickDiv} />
}
}
@@ -382,12 +611,13 @@
}
render() {
return <div onClick={this.onClickDiv} />
return <div onClick={this.onClickDiv} />;
}
}
```
- Do not use underscore prefix for internal methods of a React component.
> Why? Underscore prefixes are sometimes used as a convention in other languages to denote privacy. But, unlike those languages, there is no native support for privacy in JavaScript, everything is public. Regardless of your intentions, adding underscore prefixes to your properties does not actually make them private, and any property (underscore-prefixed or not) should be treated as being public. See issues [#1024](https://github.com/airbnb/javascript/issues/1024), and [#490](https://github.com/airbnb/javascript/issues/490) for a more in-depth discussion.
```jsx
// bad
@@ -409,7 +639,7 @@
}
```
- Be sure to return a value in your `render` methods. eslint: [`require-render-return`](https://github.com/yannickcr/eslint-plugin-react/pull/502)
- Be sure to return a value in your `render` methods. eslint: [`react/require-render-return`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md)
```jsx
// bad
@@ -437,15 +667,17 @@
1. `componentWillUpdate`
1. `componentDidUpdate`
1. `componentWillUnmount`
1. *clickHandlers or eventHandlers* like `onClickSubmit()` or `onChangeDescription()`
1. *event handlers starting with 'handle'* like `handleSubmit()` or `handleChangeDescription()`
1. *event handlers starting with 'on'* like `onClickSubmit()` or `onChangeDescription()`
1. *getter methods for `render`* like `getSelectReason()` or `getFooterContent()`
1. *Optional render methods* like `renderNavigation()` or `renderProfilePicture()`
1. *optional render methods* like `renderNavigation()` or `renderProfilePicture()`
1. `render`
- How to define `propTypes`, `defaultProps`, `contextTypes`, etc...
```jsx
import React, { PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
id: PropTypes.number.isRequired,
@@ -463,7 +695,7 @@
}
render() {
return <a href={this.props.url} data-id={this.props.id}>{this.props.text}</a>
return <a href={this.props.url} data-id={this.props.id}>{this.props.text}</a>;
}
}
@@ -473,7 +705,7 @@
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)
- Ordering for `React.createClass`: eslint: [`react/sort-comp`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/sort-comp.md)
1. `displayName`
1. `propTypes`
@@ -494,15 +726,32 @@
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. *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)
- Do not use `isMounted`. eslint: [`react/no-is-mounted`](https://github.com/jsx-eslint/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)**: [jhcccc/javascript](https://github.com/jhcccc/javascript/tree/master/react)
- ![tw](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Taiwan.png) **Chinese (Traditional)**: [jigsawye/javascript](https://github.com/jigsawye/javascript/tree/master/react)
- ![es](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Spain.png) **Español**: [agrcrobles/javascript](https://github.com/agrcrobles/javascript/tree/master/react)
- ![jp](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Japan.png) **Japanese**: [mitsuruog/javascript-style-guide](https://github.com/mitsuruog/javascript-style-guide/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)
- ![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)
- ![Br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Portuguese**: [ronal2do/javascript](https://github.com/ronal2do/airbnb-react-styleguide)
- ![ru](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Russia.png) **Russian**: [leonidlebedev/javascript-airbnb](https://github.com/leonidlebedev/javascript-airbnb/tree/master/react)
- ![th](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Thailand.png) **Thai**: [lvarayut/javascript-style-guide](https://github.com/lvarayut/javascript-style-guide/tree/master/react)
- ![tr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Turkey.png) **Turkish**: [alioguzhan/react-style-guide](https://github.com/alioguzhan/react-style-guide)
- ![ua](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Ukraine.png) **Ukrainian**: [ivanzusko/javascript](https://github.com/ivanzusko/javascript/tree/master/react)
- ![vn](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Vietnam.png) **Vietnam**: [uetcodecamp/jsx-style-guide](https://github.com/UETCodeCamp/jsx-style-guide)
**[⬆ back to top](#table-of-contents)**