Skip to content

Error thrown on single-line mixin include without semicolon #110

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

Closed
jwilsson opened this issue Aug 20, 2018 · 6 comments · Fixed by #113
Closed

Error thrown on single-line mixin include without semicolon #110

jwilsson opened this issue Aug 20, 2018 · 6 comments · Fixed by #113

Comments

@jwilsson
Copy link
Collaborator

Originally reported at lesshint/lesshint#490

  • Node Version: 10.9.0
  • NPM Version: 6.2.0
  • postcss-less Version: 2.0.0

If you have a large amount of code to share which demonstrates the problem you're experiencing, please provide a link to your
repository rather than pasting code. Otherwise, please paste relevant short snippets below.

LESS

.foo{.bar("baz")}

JavaScript

const postcss = require('postcss');
const syntax = require('postcss-less');

const lessText = `.foo{.bar("baz")}`;

postcss([])
  .process(lessText, { syntax: syntax })
  .then(function (result) {
    console.log(result.root.first)
  })
  .catch((e) => {
      console.error(e);
  });

Errors

CssSyntaxError {
  name: 'CssSyntaxError',
  reason: 'Unknown word',
  source: '\n.foo{.bar("baz")}\n',
  line: 2,
  column: 16,
  message: '<css input>:2:16: Unknown word',
  input: { line: 2, column: 16, source: '\n.foo{.bar("baz")}\n' }
}

Expected Behavior

Return an AST without any errors.

Actual Behavior

The above error is thrown. Adding a semicolon before } fixes it though.

How can we reproduce the behavior?

Run the JS code above.

@zhangzhiqiang37
Copy link

Excuse me, is there any fix progress about this issue?

@shellscape
Copy link
Owner

@zhangzhiqiang37 github will show activity above if there is any. as of 20 days ago, there is no activity.

@shellscape shellscape mentioned this issue Sep 17, 2018
16 tasks
@shellscape
Copy link
Owner

Well the semicolon is just a false flag on this one. A semicolon short-circuits the parsing and returns the proper rule. But the real issue here is that there's a combination of parens and a string param there that seems to be throwing the parsing off. I've spent 4 hours and tried a half dozen different ways to resolve this and nothing will satisfy all scenarios. One fix results in other breakages.

If anyone wants this fixed, it's going to have to come from an outside contributor. 4 hours is my max.

shellscape added a commit that referenced this issue Sep 18, 2018
@shellscape
Copy link
Owner

So I ended up rewriting the entire parser on PostCSS v7. 00995e5 adds a test to assert that this doesn't throw an error any longer.

shellscape added a commit that referenced this issue Sep 21, 2018
* 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
@zhangzhiqiang37
Copy link

So... I will see this new feature in next version of lesshint? @jwilsson

@jwilsson
Copy link
Collaborator Author

@zhangzhiqiang37 Yes, eventually. There are still some things to work out with this upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants