Skip to content

Commit

Permalink
chore: upgrade to eslint 9.x (#1267)
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 authored Sep 23, 2024
1 parent 4efb294 commit 57a192a
Show file tree
Hide file tree
Showing 12 changed files with 1,108 additions and 759 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
@@ -1,3 +1,5 @@
/* eslint-disable no-console */

import { readFile } from 'node:fs/promises';
import format from 'human-format';
import memwatch from '@airbnb/node-memwatch';
Expand Down
2 changes: 2 additions & 0 deletions bench/perf/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-console */

import { readFileSync, createReadStream, readdirSync } from 'node:fs';
import Benchmark from 'benchmark';
import { loadTreeConstructionTestData } from 'parse5-test-utils/dist/generate-parsing-tests.js';
Expand Down
89 changes: 89 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import eslintjs from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import { configs as tseslintConfigs } from 'typescript-eslint';
import globals from 'globals';
import eslintUnicorn from 'eslint-plugin-unicorn';

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/',
'coverage/',
];
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,
eslintUnicorn.configs['flat/recommended'],
{
rules: {
'unicorn/no-null': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/prefer-string-slice': 'off',
'unicorn/prefer-code-point': 'off',
'unicorn/no-array-push-push': 'off',
'unicorn/no-for-loop': 'off',
'unicorn/consistent-destructuring': 'off',
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prefer-at': 'off',
'unicorn/number-literal-case': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/prefer-switch': ['error', { emptyDefaultCase: 'do-nothing-comment' }],
},
},
];
Loading

0 comments on commit 57a192a

Please sign in to comment.