Skip to content

Unexpectedly ignored words in @import #88

@lydell

Description

@lydell
  • Node Version: 8.3.0
  • NPM Version: 5.3.0
  • postcss-less Version: 1.1.0

LESS

@import missing "missing" "not missing";

JavaScript

require("postcss-less").parse('@import missing "missing" "not missing";')

Expected Behavior

Error thrown, or missing and "missing" being somewhere on the Import node.

Note: The example code is invalid Less ("malformed import statement").

Actual Behavior

The example Less code parses the same as this:

@import "not missing";

In other words, missing and "missing" are totally ignored.

How can we reproduce the behavior?

require("postcss-less").parse('@import missing "missing" "not missing";')

Background

This causes problems for Prettier when people forget the semicolon after the @import: prettier/prettier#2584

@import "../assets/font/league-gothic/league-gothic.css"

.ManagerPage {
  height: 100%;
}

... 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:

  • Either an error to be thrown
  • or "../assets/font/league-gothic/league-gothic.css" being somewhere on the Import node so that it can be printed back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions