const { builtinModules } = require('node:module'); const { defineConfig } = require('eslint-define-config'); module.exports = defineConfig({ root: true, extends: [ 'eslint:recommended', 'plugin:node/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:regexp/recommended', ], plugins: ['import', 'regexp'], parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module', ecmaVersion: 2021, }, rules: { // eqeqeq: ['warn', 'always', { null: 'never' }], 'no-debugger': ['error'], 'no-empty': ['warn', { allowEmptyCatch: true }], 'no-process-exit': 'off', 'no-useless-escape': 'off', 'prefer-const': [ 'warn', { destructuring: 'all', }, ], 'node/no-missing-import': [ 'off', { allowModules: ['types', 'estree', 'less', 'sass', 'stylus'], tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], }, ], 'no-restricted-globals': 'off', 'regexp/no-obscure-range': 'off', 'node/no-missing-require': [ 'error', { // for try-catching yarn pnp allowModules: ['pnpapi', 'ranite'], tryExtensions: ['.ts', '.js', '.jsx', '.tsx', '.d.ts'], }, ], 'node/no-extraneous-import': [ 'error', { allowModules: ['ranite', 'less', 'sass', 'vitest'], }, ], 'node/no-extraneous-require': [ 'error', { allowModules: ['ranite'], }, ], 'node/no-deprecated-api': 'off', 'node/no-unpublished-import': 'off', 'node/no-unpublished-require': 'off', 'node/no-unsupported-features/es-syntax': 'off', '@typescript-eslint/ban-ts-comment': 'off', // TODO: we should turn this on in a new PR '@typescript-eslint/ban-types': 'off', // TODO: we should turn this on in a new PR '@typescript-eslint/explicit-module-boundary-types': ['error', { allowArgumentsExplicitlyTypedAsAny: true }], '@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }], '@typescript-eslint/no-this-alias': 'off', '@typescript-eslint/no-empty-interface': 'off', '@typescript-eslint/no-explicit-any': 0, // maybe we should turn this on in a new PR ยก '@typescript-eslint/no-extra-semi': 'off', // conflicts with prettier '@typescript-eslint/no-inferrable-types': 'off', '@typescript-eslint/no-non-null-assertion': 'off', // maybe we should turn this on in a new PR '@typescript-eslint/no-unused-vars': 'off', // maybe we should turn this on in a new PR '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }], 'prefer-rest-params': 'off', 'import/no-nodejs-modules': ['error', { allow: builtinModules.map((mod) => `node:${mod}`) }], 'import/no-duplicates': 'error', 'import/order': 'error', 'sort-imports': [ 'error', { ignoreCase: false, ignoreDeclarationSort: true, ignoreMemberSort: false, memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], allowSeparatedGroups: false, }, ], 'regexp/no-contradiction-with-assertion': 'error', 'regexp/no-unused-capturing-group': [ 'error', { fixable: true, }, ], }, overrides: [ { files: ['packages/**'], excludedFiles: '**/test/**', rules: { 'no-undef': 'off', 'no-empty': 'off', 'no-constant-condition': 'off', '@typescript-eslint/no-empty-function': 'off', }, }, { files: ['packages/ranite/**'], rules: { 'no-console': ['error', { allow: ['warn', 'error', 'log'] }], // 'no-restricted-globals': ['error', 'event'], }, }, { files: ['*.js', '*.mjs', '*.cjs'], rules: { '@typescript-eslint/explicit-module-boundary-types': 'off', }, }, { files: ['*.d.ts'], rules: { '@typescript-eslint/triple-slash-reference': 'off', }, }, ], reportUnusedDisableDirectives: true, });