Skip to content

Commit

Permalink
fix: change keyword plugin and import regexp (#3668)
Browse files Browse the repository at this point in the history
* fix: change the  and  regexp match

* feat: change unit test

* chore: change desc
  • Loading branch information
iChenLei authored Nov 29, 2021
1 parent e20c295 commit ee9e13b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@impor "[email protected]";
1 change: 1 addition & 0 deletions packages/test-data/css/_main/plugi.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@plugi "plugi-typo-dont-parse-as-@plugin";
5 changes: 5 additions & 0 deletions packages/test-data/less/_main/impor.less
Original file line number Diff line number Diff line change
@@ -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 "[email protected]";
5 changes: 5 additions & 0 deletions packages/test-data/less/_main/plugi.less
Original file line number Diff line number Diff line change
@@ -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";

0 comments on commit ee9e13b

Please sign in to comment.