Skip to content

Commit

Permalink
style: tweak eslint config (#84)
Browse files Browse the repository at this point in the history
Enable rules `prefer-template` and `object-shorthand`. These can be used with
node v4.
  • Loading branch information
sudo-suhas authored and SimenB committed Feb 17, 2018
1 parent faf0403 commit 7412b82
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module.exports = {
rules: {
eqeqeq: ['error', 'smart'],
strict: 'error',
'prefer-template': 'warn',
'object-shorthand': ['warn', 'always', { avoidExplicitReturnArrows: true }],
'node/no-unsupported-features': 'error',
'prettier/prettier': 'error',
},
Expand Down
2 changes: 1 addition & 1 deletion rules/lowercase-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {
context.report({
message: '`{{ method }}`s should begin with lowercase',
data: { method: erroneousMethod },
node: node,
node,
});
}
},
Expand Down
6 changes: 3 additions & 3 deletions rules/no-disabled-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const getDocsUrl = require('./util').getDocsUrl;

function getName(node) {
function joinNames(a, b) {
return a && b ? a + '.' + b : null;
return a && b ? `${a}.${b}` : null;
}

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

return {
CallExpression: node => {
CallExpression(node) {
const functionName = getName(node.callee);

switch (functionName) {
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports = {
}
},

'CallExpression:exit': node => {
'CallExpression:exit'(node) {
const functionName = getName(node.callee);

switch (functionName) {
Expand Down
2 changes: 1 addition & 1 deletion rules/no-large-snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
(context.options[0] && context.options[0].maxSize) || 50;

return {
ExpressionStatement: node => {
ExpressionStatement(node) {
const startLine = node.loc.start.line;
const endLine = node.loc.end.line;
const lineCount = endLine - startLine;
Expand Down
6 changes: 3 additions & 3 deletions rules/no-test-prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
},
create(context) {
return {
CallExpression: node => {
CallExpression(node) {
const nodeName = getNodeName(node.callee);

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

if (firstChar === 'f') {
return nodeName.slice(1) + '.only';
return `${nodeName.slice(1)}.only`;
}

if (firstChar === 'x') {
return nodeName.slice(1) + '.skip';
return `${nodeName.slice(1)}.skip`;
}
}
40 changes: 20 additions & 20 deletions rules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const testCaseNames = Object.assign(Object.create(null), {

const getNodeName = node => {
if (node.type === 'MemberExpression') {
return node.object.name + '.' + node.property.name;
return `${node.object.name}.${node.property.name}`;
}
return node.name;
};
Expand Down Expand Up @@ -145,23 +145,23 @@ const getDocsUrl = filename => {
};

module.exports = {
method: method,
method2: method2,
argument: argument,
argument2: argument2,
expectCase: expectCase,
expectNotCase: expectNotCase,
expectResolveCase: expectResolveCase,
expectRejectCase: expectRejectCase,
expectToBeCase: expectToBeCase,
expectNotToBeCase: expectNotToBeCase,
expectToEqualCase: expectToEqualCase,
expectNotToEqualCase: expectNotToEqualCase,
expectToBeUndefinedCase: expectToBeUndefinedCase,
expectNotToBeUndefinedCase: expectNotToBeUndefinedCase,
getNodeName: getNodeName,
isDescribe: isDescribe,
isFunction: isFunction,
isTestCase: isTestCase,
getDocsUrl: getDocsUrl,
method,
method2,
argument,
argument2,
expectCase,
expectNotCase,
expectResolveCase,
expectRejectCase,
expectToBeCase,
expectNotToBeCase,
expectToEqualCase,
expectNotToEqualCase,
expectToBeUndefinedCase,
expectNotToBeUndefinedCase,
getNodeName,
isDescribe,
isFunction,
isTestCase,
getDocsUrl,
};
2 changes: 1 addition & 1 deletion rules/valid-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = {
if (node.type === 'ReturnStatement') {
context.report({
message: 'Unexpected return statement in describe callback',
node: node,
node,
});
}
});
Expand Down

0 comments on commit 7412b82

Please sign in to comment.