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

"Unclosed block" error when checking nested CSS #178

Open
jrom99 opened this issue Jan 1, 2024 · 3 comments
Open

"Unclosed block" error when checking nested CSS #178

jrom99 opened this issue Jan 1, 2024 · 3 comments
Labels
Milestone

Comments

@jrom99
Copy link

jrom99 commented Jan 1, 2024

Given a file with the following contents:

div {
    input {
        color: black;
    }
}

The following problem happens

doiuse --browsers "> 1%" test.css 
Error parsing file
file:${MY_NPM_INSTALL}/npm/lib/node_modules/doiuse/bin/cli.js:151
      throw error;
      ^

CssSyntaxError: ${PROJECT_FOLDER}/styles/test.css:1:1: Unclosed block
    at Input.error (${MY_NPM_INSTALL}//npm/lib/node_modules/doiuse/node_modules/postcss/lib/input.js:93:16)
    at Parser.unclosedBlock (${MY_NPM_INSTALL}//npm/lib/node_modules/doiuse/node_modules/postcss/lib/parser.js:574:22)
    at Parser.endFile (${MY_NPM_INSTALL}//npm/lib/node_modules/doiuse/node_modules/postcss/lib/parser.js:336:35)
    at Parser.parse (${MY_NPM_INSTALL}//npm/lib/node_modules/doiuse/node_modules/postcss/lib/parser.js:475:10)
    at parse (${MY_NPM_INSTALL}//npm/lib/node_modules/doiuse/node_modules/postcss/lib/parse.js:11:12)
    at new LazyResult (${MY_NPM_INSTALL}//share/npm/lib/node_modules/doiuse/node_modules/postcss/lib/lazy-result.js:133:16)
    at Processor.process (${MY_NPM_INSTALL}/npm/lib/node_modules/doiuse/node_modules/postcss/lib/processor.js:53:14)
    at RuleUsageTransform._transform (file:${MY_NPM_INSTALL}//npm/lib/node_modules/doiuse/lib/stream/RuleUsageTransform.js:68:29)
    at Transform._write (node:internal/streams/transform:175:8)
    at writeOrBuffer (node:internal/streams/writable:556:12) {
  reason: 'Unclosed block',
  file:  '${PROJECT_FOLDER}/styles/test.css',
  line: 1,
  column: 1,
  input: {
    column: 1,
    endColumn: undefined,
    endLine: undefined,
    line: 1,
    source: 'div {\n    input {\n        color: black;\n    }',
    url: 'file: ${PROJECT_FOLDER}/styles/test.css',
    file: ' ${PROJECT_FOLDER}/styles/test.css'
  }
}

System information

doiuse v6.0.2
Node.js v20.10.0
Ubuntu 23.10

@tjx666
Copy link

tjx666 commented Feb 16, 2024

same issue:

image

@tjx666
Copy link

tjx666 commented Feb 16, 2024

@clshortfuse
Copy link
Collaborator

It's a valid issue. Nested CSS is commonly supported now:

https://caniuse.com/css-nesting

In the meantime, you flatten the css before checking it with doiuse, much like when working with scss. Perhaps postcss supports this syntax and it's just a matter of updating the dependency.

@clshortfuse clshortfuse added this to the 6.1 milestone Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants