Skip to content

Commit

Permalink
Upgrade to Eslint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Oct 28, 2024
1 parent 4c3d2f7 commit 8f938a3
Show file tree
Hide file tree
Showing 11 changed files with 721 additions and 525 deletions.
59 changes: 0 additions & 59 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "18.x"
node-version: "20.x"
- name: Install dependencies
run: npm install
- name: Run build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'
cache: 'npm'
- name: Cache node modules
id: cache-npm
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20'
cache: 'npm'
- name: Cache node modules
id: cache-npm
Expand Down
33 changes: 14 additions & 19 deletions build/webpack.prod.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { merge } = require('webpack-merge');
const ESLintPlugin = require('eslint-webpack-plugin');
const EsLintWebpackPlugin = require('eslint-webpack-plugin');
const { umdConfig, esmConfig } = require('./webpack.base.cjs');

const entries = {
Expand All @@ -19,22 +19,25 @@ const configDevUmd = merge(umdConfig, {
}
});

const plugins = [
new EsLintWebpackPlugin({
configType: 'flat',
files: [
'src/**/*.js',
'test/unit/mocks/*.js',
'test/unit/test/**/*.js'
]
})
]

const configProdUmd = merge(umdConfig, {
mode: 'production',
entry: entries,
output: {
filename: '[name].min.js'
},
performance: { hints: false },
plugins: [
new ESLintPlugin({
files: [
'src/**/*.js',
'test/unit/mocks/*.js',
'test/unit/test/**/*.js'
]
})
]
plugins
});

const configDevEsm = merge(esmConfig, {
Expand All @@ -55,15 +58,7 @@ const configProdEsm = merge(esmConfig, {
usedExports: false,
},
performance: { hints: false },
plugins: [
new ESLintPlugin({
files: [
'src/**/*.js',
'test/unit/mocks/*.js',
'test/unit/test/**/*.js'
]
})
]
plugins
});

module.exports = [configDevUmd, configProdUmd, configDevEsm, configProdEsm];
64 changes: 64 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import globals from 'globals';

export default [{
languageOptions: {
globals: {
...globals.browser,
...globals.mocha,
...globals.node,
dashjs: true,
ManagedMediaSource: true,
WebKitMediaSource: true,
MediaSource: true,
WebKitMediaKeys: true,
MSMediaKeys: true,
MediaKeys: true,
google: true,
},

ecmaVersion: 2020,
sourceType: 'module',

parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false,
},
},

rules: {
'no-caller': 2,
'no-undef': 2,
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
caughtErrors: 'none' // Allow unused variables in catch blocks
}
],
'no-use-before-define': 0,
strict: 0,
'no-loop-func': 0,
'no-multi-spaces': 'error',

'keyword-spacing': ['error', {
before: true,
after: true,
}],

quotes: ['error', 'single', {
allowTemplateLiterals: true,
}],

indent: ['error', 4, {
SwitchCase: 1,
}],

curly: ['error', 'all'],

'space-infix-ops': ['error', {
int32Hint: true,
}],
},
}];
Loading

0 comments on commit 8f938a3

Please sign in to comment.