fix: change keyword plugin and import regexp (#3668)

* fix: change the  and  regexp match

* feat: change unit test

* chore: change desc
This commit is contained in:
Lei Chen
2021-11-29 11:17:50 +08:00
committed by GitHub
parent e20c295511
commit ee9e13b949
6 changed files with 15 additions and 2 deletions

1
.gitignore vendored
View File

@@ -6,6 +6,7 @@
.idea
*.iml
*.sublime-*
.DS_Store
# npm
node_modules

View File

@@ -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) || {};
@@ -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();

View File

@@ -0,0 +1 @@
@impor "impor-typo-dont-parse-as-@import.less";

View File

@@ -0,0 +1 @@
@plugi "plugi-typo-dont-parse-as-@plugin";

View File

@@ -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";

View File

@@ -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";