Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.
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
2 changes: 1 addition & 1 deletion camel-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function camelCase(str) {
return str.replace(/[\w-]+/g, (s) => {
return /^-?[a-z]+(?:-[a-z]+)+$/.test(s)
? s
.replace(/^-(ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '$1')
.replace(/^-(ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '$1') // eslint-disable-line regexp/no-super-linear-backtracking -- TODO: fix
.replace(/-\w/g, (uncasedStr) => uncasedStr[1].toUpperCase())
: s;
});
Expand Down
14 changes: 8 additions & 6 deletions object-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class objectParser {
.slice(parent.nodes[i - 1].raws.node.end, child.raws.node.start)
.replace(/^\s*,+/, '');
} else if (node) {
child.raws.before = source.slice(node.start, child.raws.node.start).replace(/^\s*{+/, '');
child.raws.before = source.slice(node.start, child.raws.node.start).replace(/^\s*\{+/, '');
}
});

Expand All @@ -143,10 +143,10 @@ class objectParser {
return '';
});
} else {
after = source.slice(node.start, node.end).replace(/^\s*{/, '');
after = source.slice(node.start, node.end).replace(/^\s*\{/, '');
}

parent.raws.after = after.replace(/}+\s*$/, '');
parent.raws.after = after.replace(/\}+\s*$/, '');
parent.raws.semicolon = semicolon || false;
}
}
Expand Down Expand Up @@ -217,10 +217,11 @@ class objectParser {
if (node.value.type === 'ObjectExpression') {
let rule;

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

// eslint-disable-next-line regexp/no-super-linear-backtracking -- TODO: fix
const text = node.value.match(/^(\s*)((?:\S[\s\S]*?)?)(\s*)$/);
const comment = postcss.comment({
text: text[2],
Expand Down
7 changes: 4 additions & 3 deletions object-stringifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ObjectStringifier extends Stringifier {
!/:/.test(value)
) {
value = `:${value}`;
} else if (own === 'before' && /^(decl|rule)$/.test(node.type)) {
} else if (own === 'before' && /^(?:decl|rule)$/.test(node.type)) {
value = value.replace(/\S+$/, '');
}

Expand All @@ -119,11 +119,12 @@ class ObjectStringifier extends Stringifier {
return value;
}

if (/^(prop|selector)$/i.test(prop)) {
if (/^(?:prop|selector)$/i.test(prop)) {
value = camelCase(value);

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