Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Add trailing comma function support to comma-dangle and prettier config #55

Merged
merged 6 commits into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"bracketSpacing": false,
"trailingComma": "all"
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Added a `typescript` and `typescript-react` config [[#54](https://github.com/Shopify/eslint-plugin-shopify/pull/54)]

### Changed
* `plugin:shopify/prettier` will now enforce trailing commas in function parameter calls
* `comma-dangle` will now enforce multi-line function parameters
* Removed `plugin:shopify/esnext` as an included extension of the `plugin:shopify/prettier` config. `plugin:shopify/esnext` must now be extended by the consumer to use the `plugin:shopify/prettier`.

Example (`package.json`):
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ machine:
environment:
PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
node:
version: 6.11.1
version: 8.9.1

dependencies:
override:
Expand Down
2 changes: 1 addition & 1 deletion lib/config/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ module.exports = {
require('./rules/shopify'),
require('./rules/sort-class-members'),
require('./rules/typescript'),
require('./rules/typescript-react')
require('./rules/typescript-react'),
),
};
2 changes: 1 addition & 1 deletion lib/config/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ module.exports = {
require('./rules/shopify'),
require('./rules/strict-mode'),
require('./rules/stylistic-issues'),
require('./rules/variables')
require('./rules/variables'),
),
};
2 changes: 1 addition & 1 deletion lib/config/esnext.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ module.exports = {
'no-await-in-loop': 'off',
'object-curly-spacing': 'off',
'no-invalid-this': 'off',
}
},
),
};
2 changes: 1 addition & 1 deletion lib/config/prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
'error',
{
singleQuote: true,
trailingComma: 'es5',
trailingComma: 'all',
bracketSpacing: false,
jsxBracketSameLine: false,
},
Expand Down
11 changes: 10 additions & 1 deletion lib/config/rules/possible-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ module.exports = {
// Disallow comparing against -0
'no-compare-neg-zero': 'error',
// Disallow or enforce trailing commas
'comma-dangle': ['error', 'always-multiline'],
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
},
],
// Disallow assignment in conditional expressions
'no-cond-assign': 'error',
// Disallow use of console
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/jquery-dollar-sign-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module.exports = {

const checkDescriptor = Object.getOwnPropertyDescriptor(
nonChainingMethods,
prop
prop,
);
const check = checkDescriptor && checkDescriptor.value;
if (
Expand Down Expand Up @@ -193,7 +193,7 @@ module.exports = {
if (isjQueryRef && hasRegularValue) {
context.report(
node,
'Don’t use a $-prefixed identifier for a non-jQuery value.'
'Don’t use a $-prefixed identifier for a non-jQuery value.',
);
} else if (!isjQueryRef && hasDefinitejQueryValue) {
context.report(node, 'Use a $-prefixed identifier for a jQuery value.');
Expand All @@ -214,7 +214,7 @@ module.exports = {
checkForValidjQueryReference(
node,
node.id,
getFinalAssignmentValue(node.init)
getFinalAssignmentValue(node.init),
);
}

Expand All @@ -226,7 +226,7 @@ module.exports = {
checkForValidjQueryReference(
node,
node.left,
getFinalAssignmentValue(node.right)
getFinalAssignmentValue(node.right),
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-class-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
}

getTopLevelThisAssignmentExpressions(constructor.value).forEach(
checkConstructorThisAssignment
checkConstructorThisAssignment,
);
} else {
getClassInstanceProperties(node).forEach(propertyNode => {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-early-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = {
if (hasSimplifiableConditionalBody(body)) {
context.report(
body,
'Prefer an early return to a conditionally-wrapped function body'
'Prefer an early return to a conditionally-wrapped function body',
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-twine.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
if (specifier.local.name !== 'Twine') {
context.report(
node,
'You should use "Twine" as the reference name when importing twine.'
'You should use "Twine" as the reference name when importing twine.',
);
}
});
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/rules/binary-assignment-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const validNonBooleanExamples = [].concat(
{code: `var foo = ( 'bar' ${operator} 'baz' );`, options: ['never']},
{code: `var foo; foo = 'bar' ${operator} 'baz';`},
{code: `var foo; foo = ('bar' ${operator} 'baz');`, options: ['never']},
])
]),
);

const validBooleanExamples = [].concat(
Expand All @@ -27,7 +27,7 @@ const validBooleanExamples = [].concat(
{code: `var foo; foo = ('bar' ${operator} 'baz')`},
{code: `var foo; foo = ( 'bar' ${operator} 'baz' )`},
{code: `var foo; foo = 'bar' ${operator} 'baz'`, options: ['never']},
])
]),
);

const validLogicalExamples = [
Expand Down Expand Up @@ -149,7 +149,7 @@ const invalidBooleanExamples = [].concat(
},
],
},
])
]),
);

function errors(count, needsParens) {
Expand Down Expand Up @@ -261,7 +261,7 @@ ruleTester.run('binary-assignment-parens', rule, {
valid: [].concat(
validNonBooleanExamples,
validBooleanExamples,
validLogicalExamples
validLogicalExamples,
),
invalid: [].concat(invalidBooleanExamples, invalidLogicalExamples),
});