Skip to content

checkMissedSemicolon gives incorrect colomn/token #1617

@Gusted

Description

@Gusted

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions