The main eslint config for BBC iPlayer
npm install --save-dev eslint-config-iplayer
Since this package now uses ESLint 9, consuming repos will need to update to ESLint 9 too. You will need an eslint.config.js
file, and the rules defined in this package can be imported with FlatCompat, e.g.
const FlatCompat = require('@eslint/eslintrc').FlatCompat;
const compat = new FlatCompat({
baseDirectory: __dirname
});
const ignoreList = [
'node_modules',
'dist'
];
module.exports = [
{
ignores: ignoreList
},
...compat.extends('eslint-config-iplayer/tsx')
];
eslint-config-iplayer/tsx
can be replaced with js
, jsx
, ts
, base
or legacy
as for previous versions.
Adding the following to your eslintConfig
in package.json
will import the iPlayer ES6 config rules:
{
"eslintConfig": {
"extends": "iplayer"
}
}
jsx
rules:
{
"eslintConfig": {
"extends": "iplayer/jsx"
}
}
ts
rules:
{
"eslintConfig": {
"extends": "iplayer/ts"
}
}
tsx
rules:
{
"eslintConfig": {
"extends": "iplayer/tsx"
}
}
base
rules:
{
"eslintConfig": {
"extends": "iplayer/base"
}
}
legacy
rules:
{
"eslintConfig": {
"extends": "iplayer/legacy"
}
}
This package currently sets the default ECMAScript Version to be 9 for the base rules, with the legacy
rules set to use ECMAScript Version 5. If you require a different version you can change it like so:
{
"eslintConfig": {
"extends": "iplayer"
},
"parserOptions": {
"ecmaVersion": 6
}
}