Skip to content

Commit eb4b27d

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 73d548e + 420439c commit eb4b27d

25 files changed

+8227
-8912
lines changed

.eslintignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
test/fixtures/*
1+
**/fixtures/**
22
coverage/**
3-
.nyc_output/**
3+
.nyc_output/**

.github/dependabot.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
version: 2
22
updates:
3-
- package-ecosystem: 'npm'
3+
- package-ecosystem: npm
44
directory: '/'
55
schedule:
6-
interval: 'daily'
6+
interval: montly
77
versioning-strategy: increase
8+
open-pull-requests-limit: 1
9+
labels:
10+
- 'pr: dependencies'

.husky/pre-commit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env sh
2+
[ -n "$CI" ] && exit 0
3+
4+
. "$(dirname -- "$0")/_/husky.sh"
5+
6+
npx lint-staged

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
test/fixtures/*
1+
**/fixtures/**
22
coverage/**
33
.nyc_output/**

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 0.38.0
4+
5+
- Removed: hardcoded transform from float to cssFloat in objects ([#172](https://github.com/stylelint/postcss-css-in-js/pull/172))
6+
- Fixed: silent fail if @babel/plugin-proposal-decorators is in user's Babel configuration ([#237](https://github.com/stylelint/postcss-css-in-js/pull/237))
7+
8+
## 0.37.3
9+
10+
- Fixed: silent fail if Babel config is present ([#258](https://github.com/stylelint/postcss-css-in-js/pull/258)).
11+
312
## 0.37.2
413

514
- Fixed: use HTTPS url instead of HTTP for postcss logo in README ([#39](https://github.com/stylelint/postcss-css-in-js/pull/39)).

camel-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function camelCase(str) {
44
return str.replace(/[\w-]+/g, (s) => {
55
return /^-?[a-z]+(?:-[a-z]+)+$/.test(s)
66
? s
7-
.replace(/^-(ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '$1')
7+
.replace(/^-(ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '$1') // eslint-disable-line regexp/no-super-linear-backtracking -- TODO: fix
88
.replace(/-\w/g, (uncasedStr) => uncasedStr[1].toUpperCase())
99
: s;
1010
});

extract.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,33 @@ function loadBabelOpts(opts) {
141141
}
142142

143143
opts[key] = fileOpts[key];
144+
145+
if (Array.isArray(fileOpts[key]) && Array.isArray(opts.parserOpts[key])) {
146+
// combine arrays for plugins
147+
// plugins in fileOpts could be string, array or object
148+
for (const plugin of fileOpts[key]) {
149+
const option =
150+
Array.isArray(plugin) || typeof plugin === 'string'
151+
? plugin
152+
: [plugin.key, plugin.options];
153+
154+
opts.parserOpts[key] = [...opts.parserOpts[key], option];
155+
}
156+
} else {
157+
// because some options need to be passed to parser also
158+
opts.parserOpts[key] = fileOpts[key];
159+
}
160+
}
161+
162+
// avoid conflicting with the legacy decorators plugin
163+
if (opts.plugins && opts.plugins.some((p) => p.key === 'proposal-decorators')) {
164+
const index = opts.parserOpts.plugins.findIndex(
165+
(p) => Array.isArray(p) && p[0] === 'decorators',
166+
);
167+
168+
if (index > -1) {
169+
opts.parserOpts.plugins.splice(index, 1);
170+
}
144171
}
145172

146173
return opts;

object-parser.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class objectParser {
128128
.slice(parent.nodes[i - 1].raws.node.end, child.raws.node.start)
129129
.replace(/^\s*,+/, '');
130130
} else if (node) {
131-
child.raws.before = source.slice(node.start, child.raws.node.start).replace(/^\s*{+/, '');
131+
child.raws.before = source.slice(node.start, child.raws.node.start).replace(/^\s*\{+/, '');
132132
}
133133
});
134134

@@ -143,10 +143,10 @@ class objectParser {
143143
return '';
144144
});
145145
} else {
146-
after = source.slice(node.start, node.end).replace(/^\s*{/, '');
146+
after = source.slice(node.start, node.end).replace(/^\s*\{/, '');
147147
}
148148

149-
parent.raws.after = after.replace(/}+\s*$/, '');
149+
parent.raws.after = after.replace(/\}+\s*$/, '');
150150
parent.raws.semicolon = semicolon || false;
151151
}
152152
}
@@ -217,10 +217,11 @@ class objectParser {
217217
if (node.value.type === 'ObjectExpression') {
218218
let rule;
219219

220+
// eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking -- TODO: fix
220221
if (/^@(\S+)(\s*)(.*)$/.test(key.value)) {
221-
const name = RegExp.$1;
222-
const afterName = RegExp.$2;
223-
const params = RegExp.$3;
222+
const name = RegExp.$1; // eslint-disable-line regexp/no-legacy-features -- TODO: fix
223+
const afterName = RegExp.$2; // eslint-disable-line regexp/no-legacy-features -- TODO: fix
224+
const params = RegExp.$3; // eslint-disable-line regexp/no-legacy-features -- TODO: fix
224225
const atRule = postcss.atRule({
225226
name: unCamelCase(name),
226227
raws: {
@@ -325,6 +326,7 @@ class objectParser {
325326
return this.comment(node, parent.parent);
326327
}
327328

329+
// eslint-disable-next-line regexp/no-super-linear-backtracking -- TODO: fix
328330
const text = node.value.match(/^(\s*)((?:\S[\s\S]*?)?)(\s*)$/);
329331
const comment = postcss.comment({
330332
text: text[2],

object-stringifier.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ class ObjectStringifier extends Stringifier {
2626
decl(node, semicolon) {
2727
let prop = this.rawValue(node, 'prop');
2828

29-
if (prop === 'float') {
30-
prop = 'cssFloat';
31-
}
32-
3329
let string = prop;
3430

3531
const isObjectShorthand = node.raws.node && node.raws.node.shorthand;
@@ -100,7 +96,7 @@ class ObjectStringifier extends Stringifier {
10096
!/:/.test(value)
10197
) {
10298
value = `:${value}`;
103-
} else if (own === 'before' && /^(decl|rule)$/.test(node.type)) {
99+
} else if (own === 'before' && /^(?:decl|rule)$/.test(node.type)) {
104100
value = value.replace(/\S+$/, '');
105101
}
106102

@@ -123,11 +119,12 @@ class ObjectStringifier extends Stringifier {
123119
return value;
124120
}
125121

126-
if (/^(prop|selector)$/i.test(prop)) {
122+
if (/^(?:prop|selector)$/i.test(prop)) {
127123
value = camelCase(value);
128124

125+
// eslint-disable-next-line regexp/no-unused-capturing-group -- TODO: fix
129126
if (node.raws.before && /(\S+)$/.test(node.raws.before)) {
130-
value = RegExp.$1 + value;
127+
value = RegExp.$1 + value; // eslint-disable-line regexp/no-legacy-features -- TODO: fix
131128
} else if (value && !/\W/.test(value)) {
132129
return value;
133130
}

0 commit comments

Comments
 (0)