• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import eslintjs from '@eslint/js';
2import eslintConfigPrettier from 'eslint-config-prettier';
3import { configs as tseslintConfigs } from 'typescript-eslint';
4import globals from 'globals';
5import eslintUnicorn from 'eslint-plugin-unicorn';
6
7const { configs: eslintConfigs } = eslintjs;
8
9const sourceFiles = ['bench/**/*.js', 'scripts/**/*.ts', 'packages/*/lib/**/*.ts'];
10const testFiles = ['test/**/*.{ts,js}'];
11const ignoreFiles = [
12    'test/data/html5lib-tests',
13    'test/data/html5lib-tests-fork',
14    'packages/*/dist/',
15    'test/dist/',
16    'docs/build/',
17    'coverage/',
18];
19const allFiles = [...sourceFiles, ...testFiles];
20
21export default [
22    {
23        files: allFiles,
24    },
25    {
26        ignores: ignoreFiles,
27    },
28    {
29        languageOptions: {
30            globals: {
31                ...globals.nodeBuiltin,
32                ...globals.es2019,
33            },
34        },
35    },
36    eslintConfigs.recommended,
37    ...tseslintConfigs.recommended,
38    {
39        rules: {
40            'no-console': 'error',
41            curly: ['error', 'all'],
42            'prefer-arrow-callback': 'error',
43            'one-var': ['error', 'never'],
44            'no-var': 'error',
45            'prefer-const': 'error',
46            'object-shorthand': 'error',
47            'prefer-destructuring': [
48                'error',
49                {
50                    object: true,
51                    array: false,
52                },
53            ],
54            'prefer-template': 'error',
55            'arrow-body-style': ['error', 'as-needed'],
56        },
57    },
58    {
59        files: ['**/*.ts'],
60        rules: {
61            '@typescript-eslint/no-unsafe-declaration-merging': 'off',
62            '@typescript-eslint/no-non-null-assertion': 'warn',
63            '@typescript-eslint/no-explicit-any': 'warn',
64            '@typescript-eslint/explicit-function-return-type': 'error',
65            '@typescript-eslint/consistent-type-imports': 'error',
66
67            '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
68        },
69    },
70    eslintConfigPrettier,
71    eslintUnicorn.configs['flat/recommended'],
72    {
73        rules: {
74            'unicorn/no-null': 'off',
75            'unicorn/prevent-abbreviations': 'off',
76            'unicorn/prefer-string-slice': 'off',
77            'unicorn/prefer-code-point': 'off',
78            'unicorn/no-array-push-push': 'off',
79            'unicorn/no-for-loop': 'off',
80            'unicorn/consistent-destructuring': 'off',
81            'unicorn/prefer-string-replace-all': 'off',
82            'unicorn/prefer-at': 'off',
83            'unicorn/number-literal-case': 'off',
84            'unicorn/no-nested-ternary': 'off',
85            'unicorn/consistent-function-scoping': 'off',
86            'unicorn/prefer-switch': ['error', { emptyDefaultCase: 'do-nothing-comment' }],
87        },
88    },
89];
90