Skip to content

Commit de53989

Browse files
Bump eslint-config-stylelint from 12.0.0 to 13.1.0; resolves newly-caught errors (stylelint#80)
general errors resolved: eslint/no-shadow, jest/valid-title, jest/no-conditional-expect * Bump eslint-config-stylelint from 12.0.0 to 13.1.0 Bumps [eslint-config-stylelint](https://github.com/stylelint/eslint-config-stylelint) from 12.0.0 to 13.1.0. - [Release notes](https://github.com/stylelint/eslint-config-stylelint/releases) - [Changelog](https://github.com/stylelint/eslint-config-stylelint/blob/master/CHANGELOG.md) - [Commits](stylelint/eslint-config-stylelint@12.0.0...13.1.0) Signed-off-by: dependabot[bot] <support@github.com> * resolves non-test related eslint errors * resolves jest/valid-title errors * changes template literal to be easier to read, thanks @ybiquitous * resolves last two cases of jest/no-conditional-expect Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matt Wang <matt@matthewwang.me>
1 parent 6ffab8c commit de53989

12 files changed

+116
-59
lines changed

camel-case.js

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

extract.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ function literalParser(source, opts, styles) {
417417
return;
418418
}
419419

420-
const quasis = node.quasis.map((node) => ({
421-
start: node.start,
422-
end: node.end,
420+
const quasis = node.quasis.map((quasiNode) => ({
421+
start: quasiNode.start,
422+
end: quasiNode.end,
423423
}));
424424
const style = {
425425
startIndex: quasis[0].start,
@@ -428,9 +428,9 @@ function literalParser(source, opts, styles) {
428428
};
429429

430430
if (node.expressions.length) {
431-
const expressions = node.expressions.map((node) => ({
432-
start: node.start,
433-
end: node.end,
431+
const expressions = node.expressions.map((expressionNode) => ({
432+
start: expressionNode.start,
433+
end: expressionNode.end,
434434
}));
435435

436436
style.syntax = loadSyntax(opts, __dirname);

package-lock.json

Lines changed: 80 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"codecov": "^3.8.1",
9393
"eslint": "^7.21.0",
9494
"eslint-config-prettier": "^8.1.0",
95-
"eslint-config-stylelint": "^12.0.0",
95+
"eslint-config-stylelint": "^13.1.0",
9696
"husky": "^5.1.3",
9797
"is-ci": "^3.0.0",
9898
"jest": "^26.6.3",

template-parser-helper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ function literal(start) {
4545
if (input.templateLiteralStyles) {
4646
const offset = input.quasis[0].start;
4747
const nodeIndex = getNodeIndex(node, input);
48-
const start = offset + nodeIndex;
49-
const end = start + node.text.length;
48+
const startIndex = offset + nodeIndex;
49+
const endIndex = startIndex + node.text.length;
5050
const templateLiteralStyles = input.templateLiteralStyles.filter(
51-
(style) => style.startIndex <= end && start < style.endIndex,
51+
(style) => style.startIndex <= endIndex && startIndex < style.endIndex,
5252
);
5353

5454
if (templateLiteralStyles.length) {

template-tokenize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function templateTokenize(input) {
4747
if (returned.length) {
4848
token = [
4949
returned[0][0],
50-
returned.map((token) => token[1]).join(''),
50+
returned.map((parentToken) => parentToken[1]).join(''),
5151
returned[0][2],
5252
returned[0][3],
5353
line,

test/camel-case.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('camelCase', () => {
4646
});
4747
describe('symbols', () => {
4848
symbols.forEach((symbol) => {
49-
it(JSON.stringify(symbol), () => {
49+
it(`"${symbol}"`, () => {
5050
expect(camelCase(testCases.map((testCase) => testCase.unCamel).join(symbol))).toBe(
5151
testCases.map((testCase) => testCase.camel).join(symbol),
5252
);
@@ -63,7 +63,7 @@ describe('unCamelCase', () => {
6363
});
6464
describe('symbols', () => {
6565
symbols.forEach((symbol) => {
66-
it(JSON.stringify(symbol), () => {
66+
it(`"${symbol}"`, () => {
6767
expect(unCamelCase(testCases.map((testCase) => testCase.camel).join(symbol))).toBe(
6868
testCases.map((testCase) => testCase.unCamel).join(symbol),
6969
);

test/literals.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ describe('template literals', () => {
6767
expect(document.source).toHaveProperty('lang', 'jsx');
6868

6969
expect(document.nodes).toHaveLength(9);
70+
/* eslint-disable jest/no-conditional-expect -- in the current state, the related test fixture
71+
* is likely too complicated to resolve (up to 45 checks). we should consider different approaches
72+
* in the future. for more info, see https://github.com/stylelint/postcss-css-in-js/pull/80
73+
*/
7074
document.nodes.forEach((root, i) => {
7175
switch (i) {
7276
case 0: {
@@ -101,6 +105,7 @@ describe('template literals', () => {
101105
}
102106
}
103107
});
108+
/* eslint-enable jest/no-conditional-expect */
104109
});
105110

106111
it('selector', () => {
@@ -133,7 +138,7 @@ describe('template literals', () => {
133138
from: file,
134139
})
135140
.first.nodes.forEach((rule) => {
136-
it(rule.selector, () => {
141+
it(`${rule.selector}`, () => {
137142
expect(rule.nodes).toHaveLength(1);
138143
const decl = rule.first;
139144

@@ -184,7 +189,7 @@ describe('template literals', () => {
184189
'./fixtures/tpl-decl.mjs',
185190
'./fixtures/tpl-special.mjs',
186191
].map((file) => {
187-
it(file, () => {
192+
it(`${file}`, () => {
188193
file = require.resolve(file);
189194
const code = fs.readFileSync(file);
190195

test/non-style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const syntax = require('../');
77

88
describe('not throw error for non-style js file', () => {
99
files.forEach((file) => {
10-
it(file, () => {
10+
it(`${file}`, () => {
1111
const code = fs.readFileSync(file);
1212
const document = syntax.parse(code, {
1313
from: file,

test/styled-components.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,18 @@ describe('styled-components', () => {
1919
expect(document.nodes).toHaveLength(1);
2020
expect(document.first.nodes).toHaveLength(8);
2121

22-
const lines = code
23-
.match(/^.+$/gm)
24-
.slice(3)
25-
.map((line) => line.replace(/^\s*(.+?);?\s*$/, '$1'));
26-
27-
document.first.nodes.forEach((decl, i) => {
28-
if (i) {
29-
expect(decl).toHaveProperty('type', 'decl');
30-
} else {
31-
expect(decl).toHaveProperty('type', 'comment');
32-
}
33-
34-
expect(decl.toString()).toBe(lines[i]);
35-
});
22+
// this was previously a .forEach over every line within styled.button
23+
// instead, we unwound the loop to satisfy jest/no-conditional-expect
24+
// we expect the first line to be a comment, and the next 7 to be decls
25+
// see https://github.com/stylelint/postcss-css-in-js/pull/80 for more details
26+
expect(document.first.nodes[0]).toHaveProperty('type', 'comment');
27+
expect(document.first.nodes[1]).toHaveProperty('type', 'decl');
28+
expect(document.first.nodes[2]).toHaveProperty('type', 'decl');
29+
expect(document.first.nodes[3]).toHaveProperty('type', 'decl');
30+
expect(document.first.nodes[4]).toHaveProperty('type', 'decl');
31+
expect(document.first.nodes[5]).toHaveProperty('type', 'decl');
32+
expect(document.first.nodes[6]).toHaveProperty('type', 'decl');
33+
expect(document.first.nodes[7]).toHaveProperty('type', 'decl');
3634
});
3735

3836
it('interpolation with css template literal', () => {

test/supports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('should support for each CSS in JS package', () => {
5656
'tpl-special.mjs',
5757
'material-ui.jsx',
5858
].forEach((file) => {
59-
it(file, () => {
59+
it(`${file}`, () => {
6060
file = require.resolve('./fixtures/' + file);
6161
const code = fs.readFileSync(file);
6262
const document = syntax.parse(code, {

un-camel-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function unCamelCase(str) {
44
return str.replace(/[\w-]+/g, (s) =>
55
/^[A-Z]?[a-z]*(?:[A-Z][a-z]*)+$/.test(s)
66
? s
7-
.replace(/[A-Z]/g, (s) => '-' + s.toLowerCase())
7+
.replace(/[A-Z]/g, (casedStr) => '-' + casedStr.toLowerCase())
88
.replace(/^(o|ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '-$1')
99
: s,
1010
);

0 commit comments

Comments
 (0)