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

fix: change keyword plugin and import regexp #3668

Merged
merged 3 commits into from Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,6 +6,7 @@
.idea
*.iml
*.sublime-*
.DS_Store

# npm
node_modules
Expand Down
4 changes: 2 additions & 2 deletions packages/less/src/less/parser/parser.js
Expand Up @@ -1684,7 +1684,7 @@ const Parser = function Parser(context, imports, fileInfo) {
let features;
const index = parserInput.i;

const dir = parserInput.$re(/^@import?\s+/);
const dir = parserInput.$re(/^@import\s+/);

if (dir) {
const options = (dir ? this.importOptions() : null) || {};
Expand Down Expand Up @@ -1844,7 +1844,7 @@ const Parser = function Parser(context, imports, fileInfo) {
let args;
let options;
const index = parserInput.i;
const dir = parserInput.$re(/^@plugin?\s+/);
const dir = parserInput.$re(/^@plugin\s+/);

if (dir) {
args = this.pluginArgs();
Expand Down
1 change: 1 addition & 0 deletions packages/test-data/css/_main/impor.css
@@ -0,0 +1 @@
@impor "impor-typo-dont-parse-as-@import.less";
1 change: 1 addition & 0 deletions packages/test-data/css/_main/plugi.css
@@ -0,0 +1 @@
@plugi "plugi-typo-dont-parse-as-@plugin";
5 changes: 5 additions & 0 deletions packages/test-data/less/_main/impor.less
@@ -0,0 +1,5 @@
// https://github.com/less/less.js/issues/3660
// const dir = parserInput.$re(/^@import?\s+/);
// correct regexp is /^@import\s+/
// so follow code will change nothing, parse result is same with raw less code
@impor "impor-typo-dont-parse-as-@import.less";
5 changes: 5 additions & 0 deletions packages/test-data/less/_main/plugi.less
@@ -0,0 +1,5 @@
// https://github.com/less/less.js/issues/3660
// const dir = parserInput.$re(/^@plugin?\s+/);
// correct regexp is /^@plugin\s+/
// so follow code will change nothing, parse result is same with raw less code
@plugi "plugi-typo-dont-parse-as-@plugin";