Skip to content

Commit 2eed7fb

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

39 files changed

+108
-143
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:

index.js

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

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-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
}

lib/rules/jsx-filename-extension.js

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

8686
context.report({
8787
node: invalidNode,
88-
message: 'JSX not allowed in files with extension \'' + invalidExtension + '\''
88+
message: `JSX not allowed in files with extension '${invalidExtension}'`
8989
});
9090
}
9191
};

lib/rules/jsx-handler-names.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ module.exports = {
3737
var eventHandlerPrefix = configuration.eventHandlerPrefix || 'handle';
3838
var eventHandlerPropPrefix = configuration.eventHandlerPropPrefix || 'on';
3939

40-
var EVENT_HANDLER_REGEX = new RegExp('^((props\\.' + eventHandlerPropPrefix + ')'
41-
+ '|((.*\\.)?' + eventHandlerPrefix + '))[A-Z].*$');
42-
var PROP_EVENT_HANDLER_REGEX = new RegExp('^(' + eventHandlerPropPrefix + '[A-Z].*|ref)$');
40+
var EVENT_HANDLER_REGEX = new RegExp(`^((props\\.${eventHandlerPropPrefix})|((.*\\.)?${eventHandlerPrefix}))[A-Z].*$`);
41+
var PROP_EVENT_HANDLER_REGEX = new RegExp(`^(${eventHandlerPropPrefix}[A-Z].*|ref)$`);
4342

4443
return {
4544
JSXAttribute: function(node) {
@@ -60,12 +59,12 @@ module.exports = {
6059
if (propIsEventHandler && !propFnIsNamedCorrectly) {
6160
context.report({
6261
node: node,
63-
message: 'Handler function for ' + propKey + ' prop key must begin with \'' + eventHandlerPrefix + '\''
62+
message: `Handler function for ${propKey} prop key must begin with '${eventHandlerPrefix}'`
6463
});
6564
} else if (propFnIsNamedCorrectly && !propIsEventHandler) {
6665
context.report({
6766
node: node,
68-
message: 'Prop key for ' + propValue + ' must begin with \'' + eventHandlerPropPrefix + '\''
67+
message: `Prop key for ${propValue} must begin with '${eventHandlerPropPrefix}'`
6968
});
7069
}
7170
}

lib/rules/jsx-indent-props.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ module.exports = {
128128

129129
var regExp;
130130
if (indentType === 'space') {
131-
regExp = new RegExp('^[ ' + skip + ']+');
131+
regExp = new RegExp(`^[ ${skip}]+`);
132132
} else {
133-
regExp = new RegExp('^[\t' + skip + ']+');
133+
regExp = new RegExp(`^[\t${skip}]+`);
134134
}
135135

136136
var indent = regExp.exec(src);

0 commit comments

Comments
 (0)