106 lines
3.3 KiB
TypeScript
106 lines
3.3 KiB
TypeScript
import { fixupConfigRules } from '@eslint/compat';
|
|
import { FlatCompat } from '@eslint/eslintrc';
|
|
import js from '@eslint/js';
|
|
import { flatConfigs as importXFlatConfig } from 'eslint-plugin-import-x';
|
|
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
import reactPlugin from 'eslint-plugin-react';
|
|
import { browser, es2020, node } from 'globals';
|
|
import { config, configs as tsConfigs, parser as tsParser } from 'typescript-eslint';
|
|
import type { FixupConfigArray } from '@eslint/compat';
|
|
|
|
export default config(
|
|
// Shared configs
|
|
js.configs.recommended,
|
|
...tsConfigs.recommended,
|
|
jsxA11y.flatConfigs.recommended,
|
|
importXFlatConfig.recommended,
|
|
importXFlatConfig.typescript,
|
|
eslintPluginPrettierRecommended,
|
|
...fixupConfigRules(new FlatCompat().extends('plugin:react-hooks/recommended') as FixupConfigArray),
|
|
{
|
|
files: ['**/*.{ts,tsx}'],
|
|
...reactPlugin.configs.flat.recommended,
|
|
...reactPlugin.configs.flat['jsx-runtime'],
|
|
},
|
|
// Custom config
|
|
{
|
|
ignores: ['**/build/**', '**/dist/**', '**/node_modules/**', 'chrome-extension/manifest.js'],
|
|
},
|
|
{
|
|
files: ['**/*.{ts,tsx}'],
|
|
languageOptions: {
|
|
parser: tsParser,
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'module',
|
|
parserOptions: {
|
|
ecmaFeatures: { jsx: true },
|
|
projectService: true,
|
|
},
|
|
globals: {
|
|
...browser,
|
|
...es2020,
|
|
...node,
|
|
chrome: 'readonly',
|
|
},
|
|
},
|
|
settings: {
|
|
react: {
|
|
version: 'detect',
|
|
},
|
|
},
|
|
rules: {
|
|
'react/react-in-jsx-scope': 'off',
|
|
'react/prop-types': 'off',
|
|
'prefer-const': 'error',
|
|
'no-var': 'error',
|
|
'func-style': ['error', 'expression', { allowArrowFunctions: true }],
|
|
'no-restricted-imports': [
|
|
'error',
|
|
{
|
|
name: 'type-fest',
|
|
message: 'Please import from `@extension/shared` instead of `type-fest`.',
|
|
},
|
|
],
|
|
'arrow-body-style': ['error', 'as-needed'],
|
|
'@typescript-eslint/consistent-type-imports': 'error',
|
|
'@typescript-eslint/consistent-type-exports': 'error',
|
|
'import-x/order': [
|
|
'error',
|
|
{
|
|
'newlines-between': 'never',
|
|
alphabetize: { order: 'asc', caseInsensitive: true },
|
|
groups: ['index', 'sibling', 'parent', 'internal', 'external', 'builtin', 'object', 'type'],
|
|
pathGroups: [
|
|
{
|
|
pattern: '@*/**',
|
|
group: 'internal',
|
|
position: 'before',
|
|
},
|
|
],
|
|
pathGroupsExcludedImportTypes: ['type'],
|
|
},
|
|
],
|
|
'import-x/no-unresolved': 'off',
|
|
'import-x/no-named-as-default': 'error',
|
|
'import-x/no-named-as-default-member': 'error',
|
|
'import-x/newline-after-import': 'error',
|
|
'import-x/no-deprecated': 'error',
|
|
'import-x/no-duplicates': ['error', { considerQueryString: true, 'prefer-inline': false }],
|
|
'import-x/consistent-type-specifier-style': 'error',
|
|
'import-x/exports-last': 'error',
|
|
'import-x/first': 'error',
|
|
},
|
|
linterOptions: {
|
|
reportUnusedDisableDirectives: 'error',
|
|
},
|
|
},
|
|
// Overrides Rules
|
|
{
|
|
files: ['**/packages/shared/**/*.ts'],
|
|
rules: {
|
|
'no-restricted-imports': 'off',
|
|
},
|
|
},
|
|
);
|