-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Unexpectedly ignored words in @import #88
Comments
hm that's a bummer. in these kinds of situations it's helpful to have an example of the AST if they AST isn't correct, or is missing things. perfectly acceptable and encouraged to provide that via gist or inline if it's not too bananas. so we need a few questions answered here:
|
Here's the AST from
AFAIK, the semicolon is required in CSS, SCSS and Less. But none of the postcss parsers throw errors for missing semicolons. But the semicolon is a bit of a red herring for this issue. Also, both @import "../assets/font/league-gothic/league-gothic.css"
.ManagerPage {
height: 100%;
}
That's what we're here to discuss :) Both
In other words, they don't do anything special for (Also, while I have your attention: Would you mind taking a look at shellscape/postcss-values-parser#36? That's another thing needed for Prettier :) ) |
Interesting. I could see this being a valuable addition to postcss once complete. I'm open to suggestions as to how to represent the other bits that are being dropped from the Node. We should follow the spec as closely as possible, while making adjustments for LESS (with things such as directives, which don't exist in the spec) @import [ <url> | <string> ] <media-query-list>? ; |
What does "this" mean here? :) |
Copying in examples from the spec for convenience: @import url("fineprint.css") print;
@import url("bluish.css") projection, tv;
@import url("narrow.css") handheld and (max-width: 400px); |
"this" would be a fully functioning |
I not sure that makes sense. As far as I know, postcss does not treat any at-rule in specially, and just stores everything after |
Storing |
parser-postcss parses `@import` at-rules specially, and unfortunately buggily. This monkey-patches parser-postcss to parse all at-rules the same way. Fixes prettier#2584. postcss-less bug: shellscape/postcss-less#88
parser-postcss parses `@import` at-rules specially, and unfortunately buggily. This monkey-patches parser-postcss to parse all at-rules the same way. Fixes #2584. postcss-less bug: shellscape/postcss-less#88
@lydell ping. any interest in a PR for this one? |
No, no interest. I wish I had, though. |
* chore: fix linting errors * chore: de-esm * chore: de-esm, start move to ava * chore: move to circle * chore: gulp to npm scripts, housekeeping * chore: unfuck prev de-esm * test: get root tests passing * test: better integration tests * test: finish ava migration * chore: clean up package, add code coverage * chore(ci): fix lint script * test: ignore postcss-parser-tests until after 7.x update * chore(ci): add node 6 to circle config * fix: fixes #88, malformed filenames and missing semicolons in imports * fix: fixes #89, case insensitive !important * chore: keep the old parsers around for reference temporarily * refactor: leverage postcss 7.0 * refactor: enable mixins * chore: improve linting, fix variable parse, enable sanity check tests * chore: get stringifying working * chore: re-implement stringifying, update tests, remove old /lib * test: add test for #110 * test: add test for #108 * chore: implement interpolation, update tests * fix: fixes #102 and #86 * chore: code cleanup
LESS
JavaScript
Expected Behavior
Error thrown, or
missing
and"missing"
being somewhere on theImport
node.Note: The example code is invalid Less ("malformed import statement").
Actual Behavior
The example Less code parses the same as this:
In other words,
missing
and"missing"
are totally ignored.How can we reproduce the behavior?
Background
This causes problems for Prettier when people forget the semicolon after the
@import
: prettier/prettier#2584... is turned into this by Prettier:
@import .ManagerPage { height: 100%; }
... because
"../assets/font/league-gothic/league-gothic.css"
is entirely missing from the AST. Prettier would need:"../assets/font/league-gothic/league-gothic.css"
being somewhere on theImport
node so that it can be printed back.The text was updated successfully, but these errors were encountered: