Compare commits

..

20 Commits

Author SHA1 Message Date
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
11 changed files with 132 additions and 1824 deletions

View File

@@ -7,7 +7,7 @@
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/airbnb/javascript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
Other Style Guides
- [ES5](es5/)
- [ES5 (Deprecated)](https://github.com/airbnb/javascript/tree/es5-deprecated/es5)
- [React](react/)
- [CSS & Sass](https://github.com/airbnb/css)
- [Ruby](https://github.com/airbnb/ruby)
@@ -153,43 +153,6 @@ Other Style Guides
const item = {};
```
<a name="objects--reserved-words"></a><a name="3.2"></a>
- [3.2](#objects--reserved-words) If your code will be executed in browsers in script context, don't use [reserved words](http://es5.github.io/#x7.6.1) as keys. It won't work in IE8. [More info](https://github.com/airbnb/javascript/issues/61). Its OK to use them in ES6 modules and server-side code. jscs: [`disallowIdentifierNames`](http://jscs.info/rule/disallowIdentifierNames)
```javascript
// bad
const superman = {
default: { clark: 'kent' },
private: true,
};
// good
const superman = {
defaults: { clark: 'kent' },
hidden: true,
};
```
<a name="objects--reserved-words-2"></a><a name="3.3"></a>
- [3.3](#objects--reserved-words-2) Use readable synonyms in place of reserved words. jscs: [`disallowIdentifierNames`](http://jscs.info/rule/disallowIdentifierNames)
```javascript
// bad
const superman = {
class: 'alien',
};
// bad
const superman = {
klass: 'alien',
};
// good
const superman = {
type: 'alien',
};
```
<a name="es6-computed-properties"></a><a name="3.4"></a>
- [3.4](#es6-computed-properties) Use computed property names when creating objects with dynamic property names.
@@ -512,30 +475,32 @@ Other Style Guides
// bad
const name = "Capt. Janeway";
// bad - template literals should contain interpolation or newlines
const name = `Capt. Janeway`;
// good
const name = 'Capt. Janeway';
```
<a name="strings--line-length"></a><a name="6.2"></a>
- [6.2](#strings--line-length) Strings that cause the line to go over 100 characters should be written across multiple lines using string concatenation.
- [6.2](#strings--line-length) Strings that cause the line to go over 100 characters should not be written across multiple lines using string concatenation.
<a name="strings--concat-perf"></a><a name="6.3"></a>
- [6.3](#strings--concat-perf) Note: If overused, long strings with concatenation could impact performance. [jsPerf](http://jsperf.com/ya-string-concat) & [Discussion](https://github.com/airbnb/javascript/issues/40).
> Why? Broken strings are painful to work with and make code less searchable.
```javascript
// bad
const errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';
// bad
const errorMessage = 'This is a super long error that was thrown because \
of Batman. When you stop to think about how Batman had anything to do \
with this, you would get nowhere \
fast.';
// good
// bad
const errorMessage = 'This is a super long error that was thrown because ' +
'of Batman. When you stop to think about how Batman had anything to do ' +
'with this, you would get nowhere fast.';
// good
const errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';
```
<a name="es6-template-literals"></a><a name="6.4"></a>
@@ -588,7 +553,7 @@ Other Style Guides
## Functions
<a name="functions--declarations"></a><a name="7.1"></a>
- [7.1](#functions--declarations) Use function declarations instead of function expressions. jscs: [`requireFunctionDeclarations`](http://jscs.info/rule/requireFunctionDeclarations)
- [7.1](#functions--declarations) Use function declarations instead of function expressions. eslint: [`func-style`](http://eslint.org/docs/rules/func-style) jscs: [`requireFunctionDeclarations`](http://jscs.info/rule/requireFunctionDeclarations)
> Why? Function declarations are named, so they're easier to identify in call stacks. Also, the whole body of a function declaration is hoisted, whereas only the reference of a function expression is hoisted. This rule makes it possible to always use [Arrow Functions](#arrow-functions) in place of function expressions.
@@ -730,7 +695,7 @@ Other Style Guides
```
<a name="functions--constructor"></a><a name="7.10"></a>
- [7.10](#functions--constructor) Never use the Function constructor to create a new function.
- [7.10](#functions--constructor) Never use the Function constructor to create a new function. eslint: [`no-new-func`](http://eslint.org/docs/rules/no-new-func)
> Why? Creating a function in this way evaluates a string similarly to eval(), which opens vulnerabilities.
@@ -743,7 +708,7 @@ Other Style Guides
```
<a name="functions--signature-spacing"></a><a name="7.11"></a>
- [7.11](#functions--signature-spacing) Spacing in a function signature.
- [7.11](#functions--signature-spacing) Spacing in a function signature. eslint: [`space-before-function-paren`](http://eslint.org/docs/rules/space-before-function-paren) [`space-before-blocks`](http://eslint.org/docs/rules/space-before-blocks)
> Why? Consistency is good, and you shouldnt have to add or remove a space when adding or removing a name.
@@ -799,6 +764,27 @@ Other Style Guides
}
```
<a name="functions--spread-vs-apply"></a><a name="7.14"></a>
- [7.14](#functions--spread-vs-apply) Prefer the use of the spread operator `...` to call variadic functions. eslint: [`prefer-spread`](http://eslint.org/docs/rules/prefer-spread)
> Why? It's cleaner, you don't need to supply a context, and you can not easily compose `new` with `apply`.
```javascript
// bad
const x = [1, 2, 3, 4, 5];
console.log.apply(console, x);
// good
const x = [1, 2, 3, 4, 5];
console.log(...x);
// bad
new (Function.prototype.bind.apply(Date, [null, 2016, 08, 05]));
// good
new Date(...[2016, 08, 05]);
```
**[⬆ back to top](#table-of-contents)**
## Arrow Functions
@@ -1334,7 +1320,7 @@ Other Style Guides
## Variables
<a name="variables--const"></a><a name="13.1"></a>
- [13.1](#variables--const) Always use `const` to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that.
- [13.1](#variables--const) Always use `const` to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that. eslint: [`no-undef`](http://eslint.org/docs/rules/no-undef) [`prefer-const`](http://eslint.org/docs/rules/prefer-const)
```javascript
// bad
@@ -2362,7 +2348,7 @@ Other Style Guides
## Naming Conventions
<a name="naming--descriptive"></a><a name="22.1"></a>
- [22.1](#naming--descriptive) Avoid single letter names. Be descriptive with your naming.
- [22.1](#naming--descriptive) Avoid single letter names. Be descriptive with your naming. eslint: [`id-length`](http://eslint.org/docs/rules/id-length)
```javascript
// bad
@@ -2904,6 +2890,7 @@ Other Style Guides
- **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript)
- **Springload**: [springload/javascript](https://github.com/springload/javascript)
- **StratoDem Analytics**: [stratodem/javascript](https://github.com/stratodem/javascript)
- **SteelKiwi Development**: [steelkiwi/javascript](https://github.com/steelkiwi/javascript)
- **StudentSphere**: [studentsphere/javascript](https://github.com/studentsphere/guide-javascript)
- **SysGarage**: [sysgarage/javascript-style-guide](https://github.com/sysgarage/javascript-style-guide)
- **Syzygy Warsaw**: [syzygypl/javascript](https://github.com/syzygypl/javascript)

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,8 @@
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

View File

@@ -1,12 +1,12 @@
{
"name": "eslint-config-airbnb-base",
"version": "5.0.1",
"version": "5.0.2",
"description": "Airbnb's base JS ESLint config, following our styleguide",
"main": "index.js",
"scripts": {
"lint": "eslint .",
"tests-only": "babel-tape-runner ./test/test-*.js",
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test)",
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"travis": "npm run --silent test"
@@ -47,15 +47,16 @@
"devDependencies": {
"babel-preset-airbnb": "^2.0.0",
"babel-tape-runner": "^2.0.1",
"eslint": "^3.2.0",
"eslint-find-rules": "^1.11.1",
"eslint-plugin-import": "^1.12.0",
"eslint": "^3.3.0",
"eslint-find-rules": "^1.13.0",
"eslint-plugin-import": "^1.13.0",
"in-publish": "^2.0.0",
"safe-publish-latest": "^1.0.1",
"tape": "^4.6.0"
},
"peerDependencies": {
"eslint": "^3.2.0",
"eslint-plugin-import": "^1.12.0"
"eslint": "^3.3.0",
"eslint-plugin-import": "^1.13.0"
},
"engines": {
"node": ">= 4"

View File

@@ -89,6 +89,10 @@ module.exports = {
// disallow the use of leading or trailing decimal points in numeric literals
'no-floating-decimal': 2,
// disallow reassignments of native objects or read-only globals
// http://eslint.org/docs/rules/no-global-assign
'no-global-assign': [2, { exceptions: [] }],
// disallow implicit type conversions
// http://eslint.org/docs/rules/no-implicit-coercion
'no-implicit-coercion': [0, {
@@ -136,7 +140,8 @@ module.exports = {
'no-multi-str': 2,
// disallow reassignments of native objects
'no-native-reassign': 2,
// TODO: deprecated in favor of no-global-assign
'no-native-reassign': 0,
// disallow use of new operator when not part of the assignment or comparison
'no-new': 2,

View File

@@ -64,7 +64,8 @@ module.exports = {
'no-irregular-whitespace': 2,
// disallow negation of the left operand of an in expression
'no-negated-in-lhs': 2,
// TODO: deprecated in favor of no-unsafe-negation
'no-negated-in-lhs': 0,
// disallow the use of object properties of the global object (Math and JSON) as functions
'no-obj-calls': 2,
@@ -79,6 +80,11 @@ module.exports = {
// disallow sparse arrays
'no-sparse-arrays': 2,
// Disallow template literal placeholder syntax in regular strings
// http://eslint.org/docs/rules/no-template-curly-in-string
// TODO: enable, semver-major
'no-template-curly-in-string': 0,
// Avoid code that looks like two expressions but is actually one
// http://eslint.org/docs/rules/no-unexpected-multiline
'no-unexpected-multiline': 2,
@@ -90,6 +96,10 @@ module.exports = {
// http://eslint.org/docs/rules/no-unsafe-finally
'no-unsafe-finally': 2,
// disallow negating the left operand of relational operators
// http://eslint.org/docs/rules/no-unsafe-negation
'no-unsafe-negation': 2,
// disallow comparisons with the value NaN
'use-isnan': 2,

View File

@@ -28,6 +28,11 @@ module.exports = {
// enforce newline at the end of file, with no multiple empty lines
'eol-last': 2,
// enforce spacing between functions and their invocations
// http://eslint.org/docs/rules/func-call-spacing
// TODO: enable, semver-minor
'func-call-spacing': [0, 'never'],
// require function expressions to have a name
'func-names': 1,
@@ -264,6 +269,9 @@ module.exports = {
// enforce spacing before and after semicolons
'semi-spacing': [2, { before: false, after: true }],
// requires object keys to be sorted
'sort-keys': [0, 'asc', { caseSensitive: false, natural: true }],
// sort variables within the same declaration block
'sort-vars': 0,

View File

@@ -1,3 +1,41 @@
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

View File

@@ -1,12 +1,12 @@
{
"name": "eslint-config-airbnb",
"version": "9.0.1",
"version": "10.0.1",
"description": "Airbnb's ESLint config, following our styleguide",
"main": "index.js",
"scripts": {
"lint": "eslint .",
"tests-only": "babel-tape-runner ./test/test-*.js",
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test)",
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test) && safe-publish-latest",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"travis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link eslint-config-airbnb-base && npm run --silent test ; npm unlink eslint-config-airbnb-base >/dev/null &"
@@ -45,24 +45,25 @@
},
"homepage": "https://github.com/airbnb/javascript",
"dependencies": {
"eslint-config-airbnb-base": "^5.0.1"
"eslint-config-airbnb-base": "^5.0.2"
},
"devDependencies": {
"babel-preset-airbnb": "^2.0.0",
"babel-tape-runner": "^2.0.1",
"eslint": "^3.2.2",
"eslint-find-rules": "^1.11.1",
"eslint-plugin-import": "^1.12.0",
"eslint-plugin-jsx-a11y": "^2.0.1",
"eslint": "^3.3.0",
"eslint-find-rules": "^1.13.0",
"eslint-plugin-import": "^1.13.0",
"eslint-plugin-jsx-a11y": "^2.1.0",
"eslint-plugin-react": "^6.0.0",
"in-publish": "^2.0.0",
"react": ">= 0.13.0",
"react": "> 0.13.0",
"safe-publish-latest": "^1.0.1",
"tape": "^4.6.0"
},
"peerDependencies": {
"eslint": "^3.2.2",
"eslint-plugin-jsx-a11y": "^2.0.1",
"eslint-plugin-import": "^1.12.0",
"eslint": "^3.3.0",
"eslint-plugin-jsx-a11y": "^2.1.0",
"eslint-plugin-import": "^1.13.0",
"eslint-plugin-react": "^6.0.0"
},
"engines": {

View File

@@ -7,6 +7,11 @@ module.exports = {
jsx: true
},
rules: {
// Enforce that anchors have content
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md
// TODO: enable, semver-major
'jsx-a11y/anchor-has-content': [0, ['']],
// 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,

View File

@@ -337,7 +337,7 @@
// good
<Foo
ref={(ref) => this.myRef = ref}
ref={ref => { this.myRef = ref; }}
/>
```
@@ -575,5 +575,6 @@
- ![pl](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Poland.png) **Polish**: [pietraszekl/javascript](https://github.com/pietraszekl/javascript/tree/master/react)
- ![kr](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/South-Korea.png) **Korean**: [apple77y/javascript](https://github.com/apple77y/javascript/tree/master/react)
- ![Br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Portuguese**: [ronal2do/javascript](https://github.com/ronal2do/airbnb-react-styleguide)
- ![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)
**[⬆ back to top](#table-of-contents)**