pugjs / pug-lint

An unopinionated and configurable linter and style checker for Pug
ISC License
228 stars 51 forks source link

validate-attribute-separator raise error on asterisk mark #116

Closed pandora2000 closed 7 years ago

pandora2000 commented 8 years ago

When I run lint with validate-attribute-seperator on Angular 2 pug template, I get following error. This is because attribute name(in this case *ngIf)'s regex is not escaped properly. I will create PR. Please wait a moment.

+ pug-lint ./src/index.pug ./src/main/app/components/app-header.pug ./src/main/app/components/app.pug ./src/main/auth/components/sign-in.pug
/home/vagrant/works/tento-4/node_modules/pug-lint/lib/rules/validate-attribute-separator.js:124
      var regexReplace = new RegExp(patterns.join('|'), 'g');
                         ^

SyntaxError: Invalid regular expression: /*ngIf\s*\!*=\s*'authenticated'|(click)\s*\!*=\s*'signOut\.emit\(\)'|href\s*\!*=\s*''/: Nothing to repeat
    at RegExp (native)
    at getParsedSource (/home/vagrant/works/tento-4/node_modules/pug-lint/lib/rules/validate-attribute-separator.js:124:26)
    at /home/vagrant/works/tento-4/node_modules/pug-lint/lib/rules/validate-attribute-separator.js:102:24
    at /home/vagrant/works/tento-4/node_modules/pug-lint/lib/pug-file.js:367:7
    at Array.forEach (native)
    at Object.iterateTokensByFilter (/home/vagrant/works/tento-4/node_modules/pug-lint/lib/pug-file.js:366:36)
    at Object.iterateTokensByType (/home/vagrant/works/tento-4/node_modules/pug-lint/lib/pug-file.js:374:10)
    at Object.lint (/home/vagrant/works/tento-4/node_modules/pug-lint/lib/rules/validate-attribute-separator.js:73:10)
    at /home/vagrant/works/tento-4/node_modules/pug-lint/lib/linter.js:145:12
    at Array.forEach (native)
giniedp commented 8 years ago

+1 please merge

julienpa commented 7 years ago

Would this also fix #100?