eslint-plugin-compat icon indicating copy to clipboard operation
eslint-plugin-compat copied to clipboard

Lookbehind in regular expressions not reported even though it is not supported on Safari browser

Open Zhouqchao opened this issue 1 year ago • 2 comments

lookbehind in regular expresions should report an error because it is not supported on Safari browser. image

here is my browserslist config:

{
	"browserslist": [
	    "last 2 years",
	    "not dead"
	  ]
}

and here is my eslint config:

module.exports = {
	root: true,
	env: {
	  browser: true,
	},
	plugins: ['compat'],
	settings: {
	  lintAllEsApis: true,
	},
	extends: ['plugin:compat/recommended'],
	parserOptions: {
	  ecmaVersion: 2018,
	  parser: 'babel-eslint',
	  sourceType: 'module',
	},
	rules: {
	  'compat/compat': 'error',
	}
}

I do get an error for OffscreenCanvas not being supported on Safari 14, so it looks like I have set up the plugin correctly. image

Zhouqchao avatar Mar 23 '23 05:03 Zhouqchao

I was literally about to install this plugin to lint for this use case. This is a bummer

MrHBS avatar Jul 21 '23 08:07 MrHBS

For a basic workaround (that unfortunately doesn't take Browserslist settings into account):

rules: {
  "no-restricted-syntax": [
    "error",
    {
      selector: "Literal[regex][raw=/\\(\\?<[=!]/]",
      message:
        "Lookbehind assertions are not supported in some browsers (e.g. Safari 16.3).",
    },
  ],
},

RobinBlomberg avatar Jun 24 '24 09:06 RobinBlomberg