Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkMissedSemicolon gives incorrect colomn/token #1617

Closed
Gusted opened this issue Jul 21, 2021 · 2 comments · Fixed by #1618
Closed

checkMissedSemicolon gives incorrect colomn/token #1617

Gusted opened this issue Jul 21, 2021 · 2 comments · Fixed by #1618
Labels

Comments

@Gusted
Copy link
Contributor

Gusted commented Jul 21, 2021

Hi!

Coming off from a issue with stylelint, seems like that the postCSS parser is returning an incorrect token/column from the checkMissedSemicolon function.

A simple test-case:

test.css
div {
        color: red !important
        background-color: #000
}
gusted@gusted-beast [15:38:26] [~] 
-> % node -pe 'require("postcss").parse(fs.readFileSync("test.css", "utf-8"))'

/usr/lib/node_modules/postcss/lib/parse.js:33
    throw e
    ^

CssSyntaxError: <css input>:2:20: Missed semicolon
    at Input.error (/usr/lib/node_modules/postcss/lib/input.js:123:16)
    at Parser.checkMissedSemicolon (/usr/lib/node_modules/postcss/lib/parser.js:555:22)
    at Parser.decl (/usr/lib/node_modules/postcss/lib/parser.js:253:12)
    at Parser.other (/usr/lib/node_modules/postcss/lib/parser.js:147:12)
    at Parser.parse (/usr/lib/node_modules/postcss/lib/parser.js:59:16)
    at Function.parse (/usr/lib/node_modules/postcss/lib/parse.js:11:12)
    at [eval]:1:20
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:305:38)
    at node:internal/process/execution:81:19 {
  reason: 'Missed semicolon',
  source: 'div {\n        color: red !important\n        background-color: #000\n}\n',
  line: 2,
  column: 20,
  input: {
    line: 2,
    column: 20,
    source: 'div {\n        color: red !important\n        background-color: #000\n}\n'
  }
}

As you see it says column: 20 which is before the !important, however the error should shay it's an error at column: 30, to include the !important

@ai
Copy link
Member

ai commented Jul 21, 2021

Can you send PR? Sorry, have no resources for the project on this week.

@Gusted
Copy link
Contributor Author

Gusted commented Jul 21, 2021

Can you send PR? Sorry, have no resources for the project on this week.

No problems, #1618, got a interesting look in how PostCSS works 😄.

@ai ai closed this as completed in #1618 Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants