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

{componentName} interpolated just one time #95

Closed
AndyOGo opened this issue Dec 5, 2016 · 1 comment
Closed

{componentName} interpolated just one time #95

AndyOGo opened this issue Dec 5, 2016 · 1 comment

Comments

@AndyOGo
Copy link

AndyOGo commented Dec 5, 2016

I just started to write my config according to the docs regarding of interpolation of {componentName}.

But it just works for single interpolations, if I try to interpolate it multiple times, it throws:
Error: "^\.{componentName}(?:__{componentName})*(?:--{componentName})?|\.(?:is|has)-{componentName}$" does not produce a valid regular expression

my config

{
  "rules": {
    "plugin/selector-bem-pattern": {
      "componentName": "[a-z0-9]+(?:-[a-z0-9]+)*",
      "componentSelectors": {
        "initial": "^\\.(?:no-)?js|\\.(?:is|has)-{componentName}|\\.{componentName}(?:__{componentName})*(?:--{componentName})?$",
        "combined": "^\\.{componentName}(?:__{componentName})*(?:--{componentName})?|\\.(?:is|has)-{componentName}$"
      }
    },
  }
}

error

/.../node/v5.10.1/bin/node /.../style-guide/node_modules/stylelint/dist/cli.js -f json --stdin-filename header.scss
Error: "^\.{componentName}(?:__{componentName})*(?:--{componentName})?|\.(?:is|has)-{componentName}$" does not produce a valid regular expression
    at /.../style-guide/node_modules/postcss-bem-linter/lib/to-interpolated-regexp.js:8:15
    at module.exports (/.../style-guide/node_modules/postcss-bem-linter/lib/validate-selectors.js:25:61)
    at checkRule (/.../style-guide/node_modules/postcss-bem-linter/index.js:78:7)
    at /.../style-guide/node_modules/postcss-bem-linter/index.js:45:9
    at Array.forEach (native)
    at /.../style-guide/node_modules/postcss-bem-linter/index.js:42:14
    at /.../style-guide/node_modules/postcss/lib/container.js:241:28
    at /.../style-guide/node_modules/postcss/lib/container.js:148:26
    at Root.each (/.../style-guide/node_modules/postcss/lib/container.js:114:22)
    at Root.walk (/.../style-guide/node_modules/postcss/lib/container.js:147:21)

Process finished with exit code 1

Cause of issue

The Issue is caused by https://github.com/postcss/postcss-bem-linter/blob/master/lib/to-interpolated-regexp.js#L6, which should use Array.join() not manual concatenation.

@simonsmith
Copy link
Collaborator

Superseded by #102

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.

2 participants