| // Copyright 2026 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| import { defineConfig } from 'eslint/config'; |
| import eslint from '@eslint/js'; |
| import jsdoc from 'eslint-plugin-jsdoc'; |
| import tseslint from 'typescript-eslint'; |
| import stylistic from '@stylistic/eslint-plugin'; |
| |
| export default defineConfig( |
| eslint.configs.recommended, |
| tseslint.configs.recommended, |
| ...tseslint.configs.recommendedTypeChecked.map(config => ({ |
| ...config, |
| |
| // Only apply type-checked rules to TypeScript files. |
| files: ['**/*.ts'], |
| })), |
| ...tseslint.configs.stylisticTypeChecked.map(config => ({ |
| ...config, |
| |
| // Only apply type-checked rules to TypeScript files. |
| files: ['**/*.ts'], |
| })), |
| [ |
| { |
| ignores: ['.vscode-test/**', 'dist/**', 'test-dist/**'], |
| }, |
| |
| // Shared JS and TS rules |
| { |
| plugins: { |
| '@jsdoc': jsdoc, |
| '@stylistic': stylistic, |
| }, |
| rules: { |
| // Best Practices |
| 'prefer-promise-reject-errors': 'error', |
| 'curly': 'error', |
| 'eqeqeq': 'error', |
| |
| // JSDoc |
| '@jsdoc/require-jsdoc': 'error', |
| '@jsdoc/require-description': 'error', |
| |
| // Stylistic |
| '@stylistic/indent': ['error', 2], |
| '@stylistic/max-len': ['error', { |
| code: 100, |
| ignoreComments: true, |
| ignoreStrings: true, |
| }], |
| '@stylistic/quotes': ['error', 'single'], |
| '@stylistic/semi': ['error', 'always'], |
| }, |
| }, |
| |
| // TypeScript specific rules |
| { |
| files: ['**/*.ts'], |
| languageOptions: { |
| parserOptions: { |
| project: 'tsconfig.json', |
| }, |
| }, |
| |
| plugins: { |
| '@typescript-eslint': tseslint.plugin, |
| }, |
| |
| rules: { |
| // Additions to recommended |
| '@typescript-eslint/naming-convention': 'error', |
| }, |
| }, |
| |
| // JavaScript specific rules |
| { |
| files: ['**/*.mjs', '**/*.js'], |
| languageOptions: { |
| ecmaVersion: 'latest', |
| sourceType: 'module', |
| globals: { |
| process: 'readonly', |
| console: 'readonly', |
| }, |
| }, |
| rules: { |
| 'no-undef': 'error', |
| 'no-unused-vars': 'error', |
| }, |
| }, |
| ], |
| ); |