Clean up code

This commit is contained in:
Andrey Sitnik
2022-02-09 17:02:16 +01:00
parent deaa0cff4f
commit d62bc58e55
2 changed files with 9 additions and 4 deletions
+8 -3
View File
@@ -7,6 +7,11 @@ let AtRule = require('./at-rule')
let Root = require('./root')
let Rule = require('./rule')
const SAFE_COMMENT_NEIGHBOR = {
empty: true,
space: true
}
class Parser {
constructor(input) {
this.input = input
@@ -418,9 +423,9 @@ class Parser {
if (type === 'space' && i === length - 1 && !customProperty) {
clean = false
} else if (type === 'comment') {
prev = tokens[i - 1]
next = tokens[i + 1]
if (prev && next && prev[0] !== 'space' && next[0] !== 'space') {
prev = tokens[i - 1] ? tokens[i - 1][0] : 'empty'
next = tokens[i + 1] ? tokens[i + 1][0] : 'empty'
if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) {
value += token[1]
} else {
clean = false
+1 -1
View File
@@ -131,7 +131,7 @@
"size-limit": [
{
"path": "lib/postcss.js",
"limit": "16 KB"
"limit": "17 KB"
}
],
"eslintConfig": {