Skip to content

Commit 3cc8e84

Browse files
committed
Update trailingComma to "all" and add npm scripts for "format" and "watch"
1 parent 5fba90b commit 3cc8e84

11 files changed

+26
-21
lines changed

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
endOfLine: 'lf',
77
printWidth: 100,
88
singleQuote: true,
9-
trailingComma: 'es5',
9+
trailingComma: 'all',
1010
useTabs: true,
1111
overrides: [
1212
{

camel-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function camelCase(str) {
66
? s
77
.replace(/^-(ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '$1')
88
.replace(/-\w/g, (s) => s[1].toUpperCase())
9-
: s
9+
: s,
1010
);
1111
}
1212

extract.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ function literalParser(source, opts, styles) {
206206
nameSpace
207207
.shift()
208208
.replace(/^\W+/, '')
209-
.split(/[/\\]+/g)
209+
.split(/[/\\]+/g),
210210
);
211211

212212
if (types.isIdentifier(id)) {
@@ -432,8 +432,8 @@ function literalParser(source, opts, styles) {
432432
(targetStyle) =>
433433
targetStyle.opts &&
434434
targetStyle.opts.expressions.some(
435-
(expr) => expr.start <= style.startIndex && style.endIndex < expr.end
436-
)
435+
(expr) => expr.start <= style.startIndex && style.endIndex < expr.end,
436+
),
437437
);
438438

439439
if (target) {

object-parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function defineRaws(node, prop, prefix, suffix, props) {
4848
prefix,
4949
suffix,
5050
},
51-
props
51+
props,
5252
);
5353
}
5454

@@ -85,7 +85,7 @@ class objectParser {
8585

8686
let before = root.source.input.css.slice(
8787
startNode.start - startNode.loc.start.column,
88-
startNode.start
88+
startNode.start,
8989
);
9090

9191
if (/^\s+$/.test(before)) {

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@
3636
]
3737
},
3838
"scripts": {
39+
"format": "prettier . --write",
3940
"lint:formatting": "prettier . --check",
4041
"lint:js": "eslint .",
4142
"lint": "npm-run-all --parallel lint:*",
4243
"pretest": "npm run lint",
4344
"mocha": "mocha --no-timeouts",
4445
"test": "nyc npm run mocha",
46+
"watch": "mocha --watch",
4547
"debug": "npm run mocha -- --inspect-brk",
4648
"release": "np"
4749
},
@@ -85,6 +87,9 @@
8587
"*.{js,md,yml}": "prettier --write"
8688
},
8789
"eslintConfig": {
90+
"parserOptions": {
91+
"ecmaVersion": 2019
92+
},
8893
"extends": [
8994
"stylelint",
9095
"prettier"

template-parser-helper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function literal(start) {
4848
const start = offset + nodeIndex;
4949
const end = start + node.text.length;
5050
const templateLiteralStyles = input.templateLiteralStyles.filter(
51-
(style) => style.startIndex <= end && start < style.endIndex
51+
(style) => style.startIndex <= end && start < style.endIndex,
5252
);
5353

5454
if (templateLiteralStyles.length) {
@@ -167,7 +167,7 @@ class LocalFixer {
167167
this.object(error.input);
168168
error.message = error.message.replace(
169169
/:\d+:\d+:/,
170-
':' + error.line + ':' + error.column + ':'
170+
':' + error.line + ':' + error.column + ':',
171171
);
172172
}
173173

@@ -187,8 +187,8 @@ class LocalFixer {
187187
{
188188
map: false,
189189
},
190-
style.opts
191-
)
190+
style.opts,
191+
),
192192
);
193193
} catch (error) {
194194
if (style.ignoreErrors) {

test/camel-case.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('camelCase', () => {
4949
symbols.forEach((symbol) => {
5050
it(JSON.stringify(symbol), () => {
5151
expect(camelCase(testCases.map((testCase) => testCase.unCamel).join(symbol))).to.equal(
52-
testCases.map((testCase) => testCase.camel).join(symbol)
52+
testCases.map((testCase) => testCase.camel).join(symbol),
5353
);
5454
});
5555
});
@@ -66,7 +66,7 @@ describe('unCamelCase', () => {
6666
symbols.forEach((symbol) => {
6767
it(JSON.stringify(symbol), () => {
6868
expect(unCamelCase(testCases.map((testCase) => testCase.camel).join(symbol))).to.equal(
69-
testCases.map((testCase) => testCase.unCamel).join(symbol)
69+
testCases.map((testCase) => testCase.unCamel).join(symbol),
7070
);
7171
});
7272
});

test/css-in-js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('CSS in JS', () => {
6262
`,
6363
{
6464
from: '/fixtures/glamorous-atRule.jsx',
65-
}
65+
},
6666
).first.first.first;
6767

6868
decl.raws.prop.raw = 'WebkitBorderRadius';
@@ -82,7 +82,7 @@ describe('CSS in JS', () => {
8282
`,
8383
{
8484
from: '/fixtures/glamorous-atRule.jsx',
85-
}
85+
},
8686
).first.first.first;
8787

8888
atRule.raws.params.raw = "(minWidth: ' + minWidth + ')";

test/literals.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('template literals', () => {
2525
expect(decl).have.property('prop', 'border-bottom');
2626
expect(decl).have.property(
2727
'value',
28-
'${(props) => (props.border ? `1px solid ${color}` : "0")}'
28+
'${(props) => (props.border ? `1px solid ${color}` : "0")}',
2929
);
3030
});
3131
});
@@ -55,7 +55,7 @@ describe('template literals', () => {
5555
"${(props) =>",
5656
"(props.status === \"signed\" && \"red\") ||",
5757
"\"blue\"}",
58-
].join("\n\t\t")
58+
].join("\n\t\t"),
5959
);
6060
});
6161
});
@@ -149,15 +149,15 @@ describe('template literals', () => {
149149
? `${/\bprefix\b/.test(rule.selector) ? 'prefix-' : ''}\${prop}${
150150
/\bsuffix\b/.test(rule.selector) ? '-suffix' : ''
151151
}`
152-
: 'prop'
152+
: 'prop',
153153
);
154154
expect(decl).to.have.property(
155155
'value',
156156
/\bvalue\b/.test(rule.selector)
157157
? `${/\bprefix\b/.test(rule.selector) ? 'prefix-' : ''}\${value}${
158158
/\bsuffix\b/.test(rule.selector) ? '-suffix' : ''
159159
}`
160-
: 'value'
160+
: 'value',
161161
);
162162
});
163163
});

test/styled-components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ describe('styled-components', () => {
250250
expect(document.nodes).to.have.lengthOf(1);
251251
expect(document.first.first).to.haveOwnProperty(
252252
'prop',
253-
"margin-${/* sc-custom 'left' */ rtlSwitch}"
253+
"margin-${/* sc-custom 'left' */ rtlSwitch}",
254254
);
255255
});
256256

un-camel-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function unCamelCase(str) {
66
? s
77
.replace(/[A-Z]/g, (s) => '-' + s.toLowerCase())
88
.replace(/^(o|ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '-$1')
9-
: s
9+
: s,
1010
);
1111
}
1212

0 commit comments

Comments
 (0)