Skip to content

Commit

Permalink
Update dependencies and practies
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 7, 2023
1 parent abf10f9 commit cb8fcdc
Show file tree
Hide file tree
Showing 4 changed files with 592 additions and 315 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
version: 8
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 19
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
Expand All @@ -33,15 +33,14 @@ jobs:
node-version:
- 18
- 16
- 14
name: Node.js ${{ matrix.node-version }} Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
version: 8
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand All @@ -56,11 +55,12 @@ jobs:
strategy:
matrix:
node-version:
- 14
- 12
name: Node.js ${{ matrix.node-version }} Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v1
with:
Expand All @@ -72,6 +72,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
run: pnpm install --no-frozen-lockfile --ignore-scripts
- name: Run unit tests
run: pnpm unit
55 changes: 28 additions & 27 deletions lib/safe-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ let Comment = require('postcss/lib/comment')
let Parser = require('postcss/lib/parser')

class SafeParser extends Parser {
createTokenizer() {
this.tokenizer = tokenizer(this.input, { ignoreErrors: true })
}
checkMissedSemicolon() {}

comment(token) {
let node = new Comment()
Expand All @@ -14,9 +12,9 @@ class SafeParser extends Parser {
this.input.fromOffset(token[3]) ||
this.input.fromOffset(this.input.css.length - 1)
node.source.end = {
offset: token[3],
column: pos.col,
line: pos.line,
column: pos.col
offset: token[3] + 1
}

let text = token[1].slice(2)
Expand All @@ -34,26 +32,29 @@ class SafeParser extends Parser {
}
}

createTokenizer() {
this.tokenizer = tokenizer(this.input, { ignoreErrors: true })
}

decl(tokens) {
if (tokens.length > 1 && tokens.some(i => i[0] === 'word')) {
super.decl(tokens)
}
}

unclosedBracket() {}

unknownWord(tokens) {
this.spaces += tokens.map(i => i[1]).join('')
}

unexpectedClose() {
this.current.raws.after += '}'
}

doubleColon() {}

unnamedAtrule(node) {
node.name = ''
endFile() {
if (this.current.nodes && this.current.nodes.length) {
this.current.raws.semicolon = this.semicolon
}
this.current.raws.after = (this.current.raws.after || '') + this.spaces

while (this.current.parent) {
this.current = this.current.parent
this.current.raws.after = ''
}
this.root.source.end = this.getPosition(this.tokenizer.position())
}

precheckMissedSemicolon(tokens) {
Expand Down Expand Up @@ -81,18 +82,18 @@ class SafeParser extends Parser {
this.decl(other)
}

checkMissedSemicolon() {}
unclosedBracket() {}

endFile() {
if (this.current.nodes && this.current.nodes.length) {
this.current.raws.semicolon = this.semicolon
}
this.current.raws.after = (this.current.raws.after || '') + this.spaces
unexpectedClose() {
this.current.raws.after += '}'
}

while (this.current.parent) {
this.current = this.current.parent
this.current.raws.after = ''
}
unknownWord(tokens) {
this.spaces += tokens.map(i => i[1]).join('')
}

unnamedAtrule(node) {
node.name = ''
}
}

Expand Down
23 changes: 14 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"repository": "postcss/postcss-safe-parser",
"scripts": {
"unit": "uvu . '\\.test\\.js$'",
"test": "pnpm unit && eslint . && ./test/integration.js"
"test:unit": "pnpm unit",
"test:lint": "eslint .",
"test:integration": "node test/integration.js",
"test": "pnpm run /^test:/"
},
"engines": {
"node": ">=12.0"
Expand All @@ -38,16 +41,18 @@
"postcss": "^8.3.3"
},
"devDependencies": {
"@logux/eslint-config": "^49.0.0",
"clean-publish": "^4.1.1",
"eslint": "^8.36.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"@logux/eslint-config": "^52.0.1",
"clean-publish": "^4.2.0",
"eslint": "^8.51.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.1.0",
"eslint-plugin-node-import": "^1.0.4",
"eslint-plugin-perfectionist": "^2.1.0",
"eslint-plugin-prefer-let": "^3.0.1",
"eslint-plugin-promise": "^6.1.1",
"postcss": "^8.4.21",
"postcss-parser-tests": "^8.5.2",
"postcss": "^8.4.31",
"postcss-parser-tests": "^8.8.0",
"uvu": "^0.5.6"
},
"prettier": {
Expand Down
Loading

0 comments on commit cb8fcdc

Please sign in to comment.