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

no-invalid-regexp rule do not understand variable for flags #10112

Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly patch candidate This issue may necessitate a patch release in the next few days regression Something broke rule Relates to ESLint's core rules

Comments

@eplouhinec
Copy link

Hi all, since few times, I have an issue with linting in a regex. It seems that variables are not allowed for flags.
Tell us about your environment

  • ESLint Version: ?
  • Node Version: v6.11.3
  • npm Version: 3.10.10

What parser (default, Babel-ESLint, etc.) are you using? Babel-ESLint

Please show your full configuration:

Configuration
---
extends:
  - eslint:recommended
  - plugin:lodash/canonical
  - angular
plugins:
  - angular
  - lodash
  - compat
env:
  browser: true
  jasmine: true
# maybe one day
# parserOptions:
#   ecmaVersion: 6
rules:
  array-bracket-spacing:
    - 1
    - never
  arrow-body-style:
    - 1
    - 'as-needed'
  arrow-spacing:
    - 2
  semi:
    - 1
    - 'always'
  semi-spacing:
    - 1
  no-extra-parens:
    - 1
    - all
    - nestedBinaryExpressions: false
  quote-props:
    - 1
    - as-needed
  quotes:
    - 1
    - single
  no-whitespace-before-property:
    - 2
  object-curly-spacing:
    - 1
    - always
  key-spacing:
    - 1
  comma-dangle:
    - 2
    - 'only-multiline'
  angular/controller-name:
    - 2
    - /[A-Z].*Ctrl$/
  angular/controller-as-vm:
    - 2
    - 'ctrl'
  angular/no-http-callback:
    - 2
  angular/di-unused:
    - 1
  angular/no-service-method:
    - off
  lodash/chaining:
    - 1
    - 'always'
    - 3
  lodash/matches-shorthand:
    - 1
    - 'always'
    - 1
  lodash/matches-prop-shorthand:
    - 0
  lodash/prefer-constant:
    - off
  lodash/prefer-lodash-method:
    - 1
    - ignoreObjects:
      - 'angular.module'
      - 'elem.css'
      - 'cloneElement'
      - 'elem'
      - 'clone'
  lodash/identity-shorthand:
    - 1
  lodash/prefer-map:
    - 1
  lodash/prefer-some:
    - 1
  lodash/prefer-lodash-chain:
    - off
  lodash/prefer-reject:
    - 1
  lodash/chain-style:
    - off
  lodash/prefer-filter:
    - 1
  lodash/prefer-includes:
    - 1
  lodash/preferred-alias:
    - 1
  lodash/no-double-unwrap:
    - 1
  lodash/prefer-get:
    - 1
  lodash/no-extra-args:
    - 2
  lodash/collection-method-value:
    - 1
  lodash/unwrap:
    - 1
  lodash/prefer-is-nil:
    - 1
  lodash/prefer-noop:
    - 0
  compat/compat:
    - 1
globals:
  angular: true,
  module: true,
  inject: true,
  _: true,
  moment: true,
  require: true,
  jstz: true,
  $: true,
  protractor : true,
  browser: true,
  $$: true,
  element: true,
  by: true,
  Uint16Array: true

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

var flags = 'ig';
var regex = new RegExp('([\\w_-]+)\\s*', flags);
gulp serve

What did you expect to happen?
No error on flags.

What actually happened? Please include the actual, raw output from ESLint.
error Invalid flags supplied to RegExp constructor 'null' no-invalid-regexp

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Mar 21, 2018
@aladdin-add aladdin-add added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Mar 21, 2018
@aladdin-add
Copy link
Member

Thanks for the report! I can repro it.

@platinumazure platinumazure added regression Something broke patch candidate This issue may necessitate a patch release in the next few days labels Mar 21, 2018
This was referenced Mar 22, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 19, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly patch candidate This issue may necessitate a patch release in the next few days regression Something broke rule Relates to ESLint's core rules
Projects
None yet
3 participants