| |
| |
| |
| |
| |
|
|
| import eslint from '@eslint/js'; |
| import tseslint from 'typescript-eslint'; |
| import reactPlugin from 'eslint-plugin-react'; |
| import reactHooks from 'eslint-plugin-react-hooks'; |
| import prettierConfig from 'eslint-config-prettier'; |
| import importPlugin from 'eslint-plugin-import'; |
| import vitest from '@vitest/eslint-plugin'; |
| import globals from 'globals'; |
| import licenseHeader from 'eslint-plugin-license-header'; |
| import path from 'node:path'; |
| import url from 'node:url'; |
|
|
| |
| const __filename = url.fileURLToPath(import.meta.url); |
| const __dirname = path.dirname(__filename); |
| |
|
|
| |
| const projectRoot = __dirname; |
|
|
| export default tseslint.config( |
| { |
| |
| ignores: [ |
| 'node_modules/*', |
| '.integration-tests/**', |
| 'eslint.config.js', |
| 'packages/**/dist/**', |
| 'bundle/**', |
| 'package/bundle/**', |
| '.integration-tests/**', |
| ], |
| }, |
| eslint.configs.recommended, |
| ...tseslint.configs.recommended, |
| reactHooks.configs['recommended-latest'], |
| reactPlugin.configs.flat.recommended, |
| reactPlugin.configs.flat['jsx-runtime'], |
| { |
| |
| settings: { |
| react: { |
| version: 'detect', |
| }, |
| }, |
| }, |
| { |
| |
| files: ['packages/cli/src/**/*.{ts,tsx}'], |
| plugins: { |
| import: importPlugin, |
| }, |
| settings: { |
| 'import/resolver': { |
| node: true, |
| }, |
| }, |
| rules: { |
| ...importPlugin.configs.recommended.rules, |
| ...importPlugin.configs.typescript.rules, |
| 'import/no-default-export': 'warn', |
| 'import/no-unresolved': 'off', |
| }, |
| }, |
| { |
| |
| files: ['packages/*/src/**/*.{ts,tsx}'], |
| plugins: { |
| import: importPlugin, |
| }, |
| settings: { |
| 'import/resolver': { |
| node: true, |
| }, |
| }, |
| languageOptions: { |
| globals: { |
| ...globals.node, |
| ...globals.es2021, |
| }, |
| }, |
| rules: { |
| |
| '@typescript-eslint/array-type': ['error', { default: 'array-simple' }], |
| 'arrow-body-style': ['error', 'as-needed'], |
| curly: ['error', 'multi-line'], |
| eqeqeq: ['error', 'always', { null: 'ignore' }], |
| '@typescript-eslint/consistent-type-assertions': [ |
| 'error', |
| { assertionStyle: 'as' }, |
| ], |
| '@typescript-eslint/explicit-member-accessibility': [ |
| 'error', |
| { accessibility: 'no-public' }, |
| ], |
| '@typescript-eslint/no-explicit-any': 'error', |
| '@typescript-eslint/no-inferrable-types': [ |
| 'error', |
| { ignoreParameters: true, ignoreProperties: true }, |
| ], |
| '@typescript-eslint/consistent-type-imports': [ |
| 'error', |
| { disallowTypeAnnotations: false }, |
| ], |
| '@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }], |
| '@typescript-eslint/no-unused-vars': [ |
| 'error', |
| { |
| argsIgnorePattern: '^_', |
| varsIgnorePattern: '^_', |
| caughtErrorsIgnorePattern: '^_', |
| }, |
| ], |
| 'import/no-internal-modules': [ |
| 'error', |
| { |
| allow: [ |
| 'react-dom/test-utils', |
| 'memfs/lib/volume.js', |
| 'yargs/**', |
| 'msw/node', |
| ], |
| }, |
| ], |
| 'import/no-relative-packages': 'error', |
| 'no-cond-assign': 'error', |
| 'no-debugger': 'error', |
| 'no-duplicate-case': 'error', |
| 'no-restricted-syntax': [ |
| 'error', |
| { |
| selector: 'CallExpression[callee.name="require"]', |
| message: 'Avoid using require(). Use ES6 imports instead.', |
| }, |
| { |
| selector: 'ThrowStatement > Literal:not([value=/^\\w+Error:/])', |
| message: |
| 'Do not throw string literals or non-Error objects. Throw new Error("...") instead.', |
| }, |
| ], |
| 'no-unsafe-finally': 'error', |
| 'no-unused-expressions': 'off', |
| '@typescript-eslint/no-unused-expressions': [ |
| |
| 'error', |
| { allowShortCircuit: true, allowTernary: true }, |
| ], |
| 'no-var': 'error', |
| 'object-shorthand': 'error', |
| 'one-var': ['error', 'never'], |
| 'prefer-arrow-callback': 'error', |
| 'prefer-const': ['error', { destructuring: 'all' }], |
| radix: 'error', |
| 'default-case': 'error', |
| }, |
| }, |
| { |
| files: ['packages/*/src/**/*.test.{ts,tsx}'], |
| plugins: { |
| vitest, |
| }, |
| rules: { |
| ...vitest.configs.recommended.rules, |
| 'vitest/expect-expect': 'off', |
| 'vitest/no-commented-out-tests': 'off', |
| }, |
| }, |
| { |
| files: ['./**/*.{tsx,ts,js}'], |
| plugins: { |
| 'license-header': licenseHeader, |
| import: importPlugin, |
| }, |
| rules: { |
| 'license-header/header': [ |
| 'error', |
| [ |
| '/**', |
| ' * @license', |
| ' * Copyright 2025 Google LLC', |
| ' * SPDX-License-Identifier: Apache-2.0', |
| ' */', |
| ], |
| ], |
| 'import/enforce-node-protocol-usage': ['error', 'always'], |
| }, |
| }, |
| |
| { |
| files: ['./scripts/**/*.js', 'esbuild.config.js'], |
| languageOptions: { |
| globals: { |
| ...globals.node, |
| process: 'readonly', |
| console: 'readonly', |
| }, |
| }, |
| rules: { |
| '@typescript-eslint/no-unused-vars': [ |
| 'error', |
| { |
| argsIgnorePattern: '^_', |
| varsIgnorePattern: '^_', |
| caughtErrorsIgnorePattern: '^_', |
| }, |
| ], |
| }, |
| }, |
| { |
| files: ['packages/vscode-ide-companion/esbuild.js'], |
| languageOptions: { |
| globals: { |
| ...globals.node, |
| process: 'readonly', |
| console: 'readonly', |
| }, |
| }, |
| rules: { |
| 'no-restricted-syntax': 'off', |
| '@typescript-eslint/no-require-imports': 'off', |
| }, |
| }, |
| |
| { |
| files: ['packages/vscode-ide-companion/scripts/**/*.js'], |
| languageOptions: { |
| globals: { |
| ...globals.node, |
| process: 'readonly', |
| console: 'readonly', |
| }, |
| }, |
| rules: { |
| 'no-restricted-syntax': 'off', |
| '@typescript-eslint/no-require-imports': 'off', |
| }, |
| }, |
| |
| prettierConfig, |
| |
| { |
| files: ['./integration-tests/**/*.js'], |
| languageOptions: { |
| globals: { |
| ...globals.node, |
| process: 'readonly', |
| console: 'readonly', |
| }, |
| }, |
| rules: { |
| '@typescript-eslint/no-unused-vars': [ |
| 'error', |
| { |
| argsIgnorePattern: '^_', |
| varsIgnorePattern: '^_', |
| caughtErrorsIgnorePattern: '^_', |
| }, |
| ], |
| }, |
| }, |
| ); |
|
|