eslint-plugin-compat
eslint-plugin-compat copied to clipboard
Lookbehind in regular expressions not reported even though it is not supported on Safari browser
lookbehind
in regular expresions should report an error because it is not supported on Safari browser.
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.
I was literally about to install this plugin to lint for this use case. This is a bummer
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).",
},
],
},