Skip to content

Commit

Permalink
chore: upgrade to eslint 9.x
Browse files Browse the repository at this point in the history
Upgrades to eslint 9.x and simplifies the customisation of our config.
  • Loading branch information
43081j committed Sep 19, 2024
1 parent be4ac72 commit d788dcb
Show file tree
Hide file tree
Showing 12 changed files with 1,007 additions and 1,363 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

59 changes: 0 additions & 59 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions bench/memory/sax-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import memwatch from '@airbnb/node-memwatch';
import { SAXParser } from '../../packages/parse5-sax-parser/dist/index.js';
import { finished } from 'parse5-test-utils/dist/common.js';

/* eslint-disable no-console */

const heapDiffMeasurement = new memwatch.HeapDiff();

let maxMemUsage = 0;
Expand Down
2 changes: 2 additions & 0 deletions bench/perf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as parse5 from '../../packages/parse5/dist/index.js';
import { ParserStream as parse5Stream } from '../../packages/parse5-parser-stream/dist/index.js';
import * as parse5Upstream from 'parse5';

/* eslint-disable no-console */

const hugePagePath = new URL('../../test/data/huge-page/huge-page.html', import.meta.url);
const treeConstructionPath = new URL('../../test/data/html5lib-tests/tree-construction', import.meta.url);
const saxPath = new URL('../../test/data/sax/', import.meta.url);
Expand Down
69 changes: 69 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import eslintjs from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import { configs as tseslintConfigs } from 'typescript-eslint';
import globals from 'globals';

const { configs: eslintConfigs } = eslintjs;

const sourceFiles = ['bench/**/*.js', 'scripts/**/*.ts', 'packages/*/lib/**/*.ts'];
const testFiles = ['test/**/*.{ts,js}'];
const ignoreFiles = [
'test/data/html5lib-tests',
'test/data/html5lib-tests-fork',
'packages/*/dist/',
'test/dist/',
'docs/build/',
];
const allFiles = [...sourceFiles, ...testFiles];

export default [
{
files: allFiles,
},
{
ignores: ignoreFiles,
},
{
languageOptions: {
globals: {
...globals.nodeBuiltin,
...globals.es2019,
},
},
},
eslintConfigs.recommended,
...tseslintConfigs.recommended,
{
rules: {
'no-console': 'error',
curly: ['error', 'all'],
'prefer-arrow-callback': 'error',
'one-var': ['error', 'never'],
'no-var': 'error',
'prefer-const': 'error',
'object-shorthand': 'error',
'prefer-destructuring': [
'error',
{
object: true,
array: false,
},
],
'prefer-template': 'error',
'arrow-body-style': ['error', 'as-needed'],
},
},
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/consistent-type-imports': 'error',

'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
},
eslintConfigPrettier,
];
Loading

0 comments on commit d788dcb

Please sign in to comment.