Skip to content

Commit

Permalink
migrate to eslint 9 conf (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev authored Sep 23, 2024
1 parent 19ef4ae commit f74fec5
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 9 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm i ol@${{ matrix.ol-version }}
- run: npm run lint
- run: npm run build
- run: npm test

Expand Down
81 changes: 81 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import mocha from 'eslint-plugin-mocha';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ['test/XMLHttpRequest.cjs'],
},
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
).map(config => ({
...config,
files: ['**/*.ts'],
})),
{
plugins: {
mocha,
},

languageOptions: {
globals: {
...globals.browser,
...globals.commonjs,
...globals.node,
...globals.mocha,
},

ecmaVersion: 2017,
sourceType: 'module',
},

rules: {
'no-unused-vars': 'off',

'@typescript-eslint/no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
}],

quotes: ['error', 'single'],
semi: ['error', 'always'],
'mocha/no-exclusive-tests': 'error',
},

files: ['**/*.ts'],
},
...compat.extends('eslint:recommended').map(config => ({
...config,
files: ['**/*.js', '**/*.cjs'],
})),
{
files: ['test/*.ts'],

rules: {
'@typescript-eslint/no-unused-expressions': 'off',
},
},
{
files: ['**/*.cjs'],

languageOptions: {
sourceType: 'commonjs',
},

rules: {
'@typescript-eslint/no-require-imports': 'off'
},
}];
31 changes: 23 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"ol": ">=10.0.0 <10.3.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.0",
"@rollup/plugin-typescript": "^11.1.5",
"@types/chai": "^4.3.11",
"@types/chai-spies": "^1.0.6",
Expand All @@ -69,6 +71,7 @@
"eslint": "^9.8.0",
"eslint-plugin-mocha": "^10.2.0",
"gh-pages": "^6.1.1",
"globals": "^15.9.0",
"html-loader": "^5.0.0",
"html-webpack-plugin": "^5.6.0",
"link": "^2.1.0",
Expand Down

0 comments on commit f74fec5

Please sign in to comment.