Skip to content

Commit 7412b82

Browse files
sudo-suhasSimenB
authored andcommitted
style: tweak eslint config (#84)
Enable rules `prefer-template` and `object-shorthand`. These can be used with node v4.
1 parent faf0403 commit 7412b82

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module.exports = {
1818
rules: {
1919
eqeqeq: ['error', 'smart'],
2020
strict: 'error',
21+
'prefer-template': 'warn',
22+
'object-shorthand': ['warn', 'always', { avoidExplicitReturnArrows: true }],
2123
'node/no-unsupported-features': 'error',
2224
'prettier/prettier': 'error',
2325
},

rules/lowercase-name.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = {
6262
context.report({
6363
message: '`{{ method }}`s should begin with lowercase',
6464
data: { method: erroneousMethod },
65-
node: node,
65+
node,
6666
});
6767
}
6868
},

rules/no-disabled-tests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const getDocsUrl = require('./util').getDocsUrl;
44

55
function getName(node) {
66
function joinNames(a, b) {
7-
return a && b ? a + '.' + b : null;
7+
return a && b ? `${a}.${b}` : null;
88
}
99

1010
switch (node && node.type) {
@@ -30,7 +30,7 @@ module.exports = {
3030
let testDepth = 0;
3131

3232
return {
33-
CallExpression: node => {
33+
CallExpression(node) {
3434
const functionName = getName(node.callee);
3535

3636
switch (functionName) {
@@ -83,7 +83,7 @@ module.exports = {
8383
}
8484
},
8585

86-
'CallExpression:exit': node => {
86+
'CallExpression:exit'(node) {
8787
const functionName = getName(node.callee);
8888

8989
switch (functionName) {

rules/no-large-snapshots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
(context.options[0] && context.options[0].maxSize) || 50;
1515

1616
return {
17-
ExpressionStatement: node => {
17+
ExpressionStatement(node) {
1818
const startLine = node.loc.start.line;
1919
const endLine = node.loc.end.line;
2020
const lineCount = endLine - startLine;

rules/no-test-prefixes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
},
1515
create(context) {
1616
return {
17-
CallExpression: node => {
17+
CallExpression(node) {
1818
const nodeName = getNodeName(node.callee);
1919

2020
if (!isDescribe(node) && !isTestCase(node)) return;
@@ -40,10 +40,10 @@ function getPreferredNodeName(nodeName) {
4040
const firstChar = nodeName.charAt(0);
4141

4242
if (firstChar === 'f') {
43-
return nodeName.slice(1) + '.only';
43+
return `${nodeName.slice(1)}.only`;
4444
}
4545

4646
if (firstChar === 'x') {
47-
return nodeName.slice(1) + '.skip';
47+
return `${nodeName.slice(1)}.skip`;
4848
}
4949
}

rules/util.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const testCaseNames = Object.assign(Object.create(null), {
108108

109109
const getNodeName = node => {
110110
if (node.type === 'MemberExpression') {
111-
return node.object.name + '.' + node.property.name;
111+
return `${node.object.name}.${node.property.name}`;
112112
}
113113
return node.name;
114114
};
@@ -145,23 +145,23 @@ const getDocsUrl = filename => {
145145
};
146146

147147
module.exports = {
148-
method: method,
149-
method2: method2,
150-
argument: argument,
151-
argument2: argument2,
152-
expectCase: expectCase,
153-
expectNotCase: expectNotCase,
154-
expectResolveCase: expectResolveCase,
155-
expectRejectCase: expectRejectCase,
156-
expectToBeCase: expectToBeCase,
157-
expectNotToBeCase: expectNotToBeCase,
158-
expectToEqualCase: expectToEqualCase,
159-
expectNotToEqualCase: expectNotToEqualCase,
160-
expectToBeUndefinedCase: expectToBeUndefinedCase,
161-
expectNotToBeUndefinedCase: expectNotToBeUndefinedCase,
162-
getNodeName: getNodeName,
163-
isDescribe: isDescribe,
164-
isFunction: isFunction,
165-
isTestCase: isTestCase,
166-
getDocsUrl: getDocsUrl,
148+
method,
149+
method2,
150+
argument,
151+
argument2,
152+
expectCase,
153+
expectNotCase,
154+
expectResolveCase,
155+
expectRejectCase,
156+
expectToBeCase,
157+
expectNotToBeCase,
158+
expectToEqualCase,
159+
expectNotToEqualCase,
160+
expectToBeUndefinedCase,
161+
expectNotToBeUndefinedCase,
162+
getNodeName,
163+
isDescribe,
164+
isFunction,
165+
isTestCase,
166+
getDocsUrl,
167167
};

rules/valid-describe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module.exports = {
6868
if (node.type === 'ReturnStatement') {
6969
context.report({
7070
message: 'Unexpected return statement in describe callback',
71-
node: node,
71+
node,
7272
});
7373
}
7474
});

0 commit comments

Comments
 (0)