| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import js from '@eslint/js';
- import stylistic from '@stylistic/eslint-plugin';
- import prettier from 'eslint-config-prettier/flat';
- import importPlugin from 'eslint-plugin-import';
- import react from 'eslint-plugin-react';
- import reactHooks from 'eslint-plugin-react-hooks';
- import globals from 'globals';
- import typescript from 'typescript-eslint';
- const controlStatements = [
- 'if',
- 'return',
- 'for',
- 'while',
- 'do',
- 'switch',
- 'try',
- 'throw',
- ];
- const paddingAroundControl = [
- ...controlStatements.flatMap((stmt) => [
- { blankLine: 'always', prev: '*', next: stmt },
- { blankLine: 'always', prev: stmt, next: '*' },
- ]),
- ];
- /** @type {import('eslint').Linter.Config[]} */
- export default [
- js.configs.recommended,
- reactHooks.configs.flat['recommended-latest'],
- ...typescript.configs.recommended,
- {
- ...react.configs.flat.recommended,
- ...react.configs.flat['jsx-runtime'], // Required for React 17+
- languageOptions: {
- globals: {
- ...globals.browser,
- },
- },
- rules: {
- 'react/react-in-jsx-scope': 'off',
- 'react/prop-types': 'off',
- 'react/no-unescaped-entities': 'off',
- },
- settings: {
- react: {
- version: 'detect',
- },
- },
- },
- {
- plugins: {
- import: importPlugin,
- },
- settings: {
- 'import/resolver': {
- typescript: {
- alwaysTryTypes: true,
- project: './tsconfig.json',
- },
- node: true,
- },
- },
- rules: {
- '@typescript-eslint/no-explicit-any': 'off',
- '@typescript-eslint/consistent-type-imports': [
- 'error',
- {
- prefer: 'type-imports',
- fixStyle: 'separate-type-imports',
- },
- ],
- 'import/order': [
- 'error',
- {
- groups: [
- 'builtin',
- 'external',
- 'internal',
- 'parent',
- 'sibling',
- 'index',
- ],
- alphabetize: {
- order: 'asc',
- caseInsensitive: true,
- },
- },
- ],
- 'import/consistent-type-specifier-style': [
- 'error',
- 'prefer-top-level',
- ],
- },
- },
- {
- plugins: {
- '@stylistic': stylistic,
- },
- rules: {
- '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: false }],
- '@stylistic/padding-line-between-statements': [
- 'error',
- ...paddingAroundControl,
- ],
- },
- },
- {
- ignores: [
- 'vendor',
- 'node_modules',
- 'public',
- 'bootstrap/ssr',
- 'tailwind.config.js',
- 'vite.config.ts',
- 'resources/js/actions/**',
- 'resources/js/components/ui/*',
- 'resources/js/routes/**',
- 'resources/js/wayfinder/**',
- ],
- },
- prettier, // Turn off all rules that might conflict with Prettier
- {
- plugins: {
- '@stylistic': stylistic,
- },
- rules: {
- curly: ['error', 'all'],
- '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: false }],
- },
- },
- ];
|