Skip to content

Commit a23611e

Browse files
committed
[Breaking] drop node < 4 support.
Also, require template literals instead of concatenation, and auto fix.
1 parent 524888c commit a23611e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+125
-165
lines changed

.eslintrc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
"env": {
33
"node": true
44
},
5+
parserOptions: {
6+
ecmaVersion: 2015
7+
},
58
ecmaFeatures: {
69
jsx: true
710
},
8-
"globals": {
9-
},
10-
"plugins": [
11-
],
1211
"rules": {
1312
// Possible Errors
1413
"comma-dangle": [2, "never"],
@@ -149,10 +148,16 @@
149148
"wrap-regex": 0,
150149
// Legacy
151150
"max-depth": 0,
152-
"max-len": [2, 120],
151+
"max-len": [2, 120, {
152+
"ignoreStrings": true,
153+
"ignoreTemplateLiterals": true,
154+
"ignoreComments": true,
155+
}],
153156
"max-params": 0,
154157
"max-statements": 0,
155158
"no-plusplus": 0,
156-
"no-prototype-builtins": 2
159+
"no-prototype-builtins": 2,
160+
"prefer-template": 2,
161+
"template-curly-spacing": [2, "never"]
157162
}
158163
}

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ node_js:
44
- '6'
55
- '5'
66
- '4'
7-
- 'iojs'
8-
- '0.12'
9-
- '0.10'
107
before_script:
11-
- 'if [ "${TRAVIS_NODE_VERSION}" = "iojs" ] || [ "${TRAVIS_NODE_VERSION}" = "0.12" ] || [ "${TRAVIS_NODE_VERSION}" = "0.10" ]; then npm install eslint@2 babel-eslint@6; fi'
128
after_success:
139
- npm run coveralls
1410
matrix:

docs/rules/forbid-elements.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ This rule checks all JSX elements and `React.createElement` calls and verifies t
1616

1717
### `forbid`
1818

19-
An array of strings and/or objects. An object in this array may have the following properties:
19+
An array of strings and/or objects. An object in this array may have the following properties:
2020

2121
* `element` (required): the name of the forbidden element (e.g. `'button'`, `'Modal'`)
2222
* `message`: additional message that gets reported
2323

24-
A string item in the array is a shorthand for `{ element: string }`.
24+
A string item in the array is a shorthand for `{ element: string }`.
2525

2626
The following patterns are not considered warnings:
2727

@@ -50,7 +50,7 @@ React.createElement(Namespaced.Element);
5050

5151
// [1, { "forbid": [{ "element": "button", "message": "use <Button> instead" }, "input"] }]
5252
<div><button /><input /></div>
53-
React.createElement('div', {}, React.createElemet('button', {}, React.createElement('input')));
53+
React.createElement('div', {}, React.createElement('button', {}, React.createElement('input')));
5454
```
5555

5656
## When not to use

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function configureAsError(rules) {
8383
if (!has(rules, key)) {
8484
continue;
8585
}
86-
result['react/' + key] = 2;
86+
result[`react/${key}`] = 2;
8787
}
8888
return result;
8989
}

lib/rules/forbid-component-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module.exports = {
6161

6262
context.report({
6363
node: node,
64-
message: 'Prop `' + prop + '` is forbidden on Components'
64+
message: `Prop \`${prop}\` is forbidden on Components`
6565
});
6666
}
6767
};

lib/rules/forbid-elements.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ module.exports = {
5959
});
6060

6161
function errorMessageForElement(name) {
62-
var message = '<' + name + '> is forbidden';
62+
var message = `<${name}> is forbidden`;
6363
var additionalMessage = indexedForbidConfigs[name].message;
6464

6565
if (additionalMessage) {
66-
message = message + ', ' + additionalMessage;
66+
return `${message}, ${additionalMessage}`;
6767
}
6868

6969
return message;

lib/rules/forbid-foreign-prop-types.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*/
55
'use strict';
66

7-
var find = require('array.prototype.find');
8-
97
// ------------------------------------------------------------------------------
108
// Constants
119
// ------------------------------------------------------------------------------
@@ -47,7 +45,7 @@ module.exports = {
4745
},
4846

4947
ObjectPattern: function(node) {
50-
var propTypesNode = find(node.properties, function(property) {
48+
var propTypesNode = node.properties.find(function(property) {
5149
return property.type === 'Property' && property.key.name === 'propTypes';
5250
});
5351

lib/rules/forbid-prop-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module.exports = {
102102
if (isForbidden(target)) {
103103
context.report({
104104
node: declaration,
105-
message: 'Prop type `' + target + '` is forbidden'
105+
message: `Prop type \`${target}\` is forbidden`
106106
});
107107
}
108108
});

lib/rules/jsx-closing-bracket-location.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ module.exports = {
248248
if (correctColumn !== null) {
249249
expectedNextLine = tokens.lastProp &&
250250
(tokens.lastProp.lastLine === tokens.closing.line);
251-
data.details = ' (expected column ' + (correctColumn + 1) +
252-
(expectedNextLine ? ' on the next line)' : ')');
251+
data.details = ` (expected column ${correctColumn + 1}${expectedNextLine ? ' on the next line)' : ')'}`;
253252
}
254253

255254
context.report({
@@ -274,7 +273,7 @@ module.exports = {
274273
case 'tag-aligned':
275274
case 'line-aligned':
276275
return fixer.replaceTextRange([cachedLastAttributeEndPos, node.end],
277-
'\n' + getIndentation(tokens, expectedLocation, correctColumn) + closingTag);
276+
`\n${getIndentation(tokens, expectedLocation, correctColumn)}${closingTag}`);
278277
default:
279278
return true;
280279
}

lib/rules/jsx-curly-spacing.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = {
8383
context.report({
8484
node: node,
8585
loc: token.loc.start,
86-
message: 'There should be no newline after \'' + token.value + '\'',
86+
message: `There should be no newline after '${token.value}'`,
8787
fix: function(fixer) {
8888
var nextToken = sourceCode.getTokenAfter(token);
8989
return fixer.replaceTextRange([token.range[1], nextToken.range[0]], spaced ? ' ' : '');
@@ -101,7 +101,7 @@ module.exports = {
101101
context.report({
102102
node: node,
103103
loc: token.loc.start,
104-
message: 'There should be no newline before \'' + token.value + '\'',
104+
message: `There should be no newline before '${token.value}'`,
105105
fix: function(fixer) {
106106
var previousToken = sourceCode.getTokenBefore(token);
107107
return fixer.replaceTextRange([previousToken.range[1], token.range[0]], spaced ? ' ' : '');
@@ -119,7 +119,7 @@ module.exports = {
119119
context.report({
120120
node: node,
121121
loc: token.loc.start,
122-
message: 'There should be no space after \'' + token.value + '\'',
122+
message: `There should be no space after '${token.value}'`,
123123
fix: function(fixer) {
124124
var nextToken = sourceCode.getTokenAfter(token);
125125
var leadingComments = sourceCode.getNodeByRangeIndex(nextToken.range[0]).leadingComments;
@@ -139,7 +139,7 @@ module.exports = {
139139
context.report({
140140
node: node,
141141
loc: token.loc.start,
142-
message: 'There should be no space before \'' + token.value + '\'',
142+
message: `There should be no space before '${token.value}'`,
143143
fix: function(fixer) {
144144
var previousToken = sourceCode.getTokenBefore(token);
145145
var trailingComments = sourceCode.getNodeByRangeIndex(previousToken.range[0]).trailingComments;
@@ -159,7 +159,7 @@ module.exports = {
159159
context.report({
160160
node: node,
161161
loc: token.loc.start,
162-
message: 'A space is required after \'' + token.value + '\'',
162+
message: `A space is required after '${token.value}'`,
163163
fix: function(fixer) {
164164
return fixer.insertTextAfter(token, ' ');
165165
}
@@ -176,7 +176,7 @@ module.exports = {
176176
context.report({
177177
node: node,
178178
loc: token.loc.start,
179-
message: 'A space is required before \'' + token.value + '\'',
179+
message: `A space is required before '${token.value}'`,
180180
fix: function(fixer) {
181181
return fixer.insertTextBefore(token, ' ');
182182
}

0 commit comments

Comments
 (0)