豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 89 additions & 11 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,59 @@
*/

import js from '@eslint/js';
import stylisticPlugin from '@stylistic/eslint-plugin';
import {defineConfig, globalIgnores} from 'eslint/config';
import importPlugin from 'eslint-plugin-import';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import {defineConfig, globalIgnores} from 'eslint/config';
import checkLicensePlugin from './scripts/eslint_rules/check-license-plugin.js';

import localPlugin from './scripts/eslint_rules/local-plugin.js';

export default defineConfig([
globalIgnores(['**/node_modules', '**/build/']),
importPlugin.flatConfigs.typescript,
{
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
plugins: {js},
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',

globals: {
...globals.node,
},

parserOptions: {
projectService: {
allowDefaultProject: ['.prettierrc.cjs', 'eslint.config.mjs'],
},
},

parser: tseslint.parser,
},

plugins: {
js,
'@local': localPlugin,
'@typescript-eslint': tseslint.plugin,
'@stylistic': stylisticPlugin,
},

settings: {
'import/resolver': {
typescript: true,
},
},

extends: ['js/recommended'],
},
tseslint.configs.recommended,
tseslint.configs.stylistic,
{
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
languageOptions: {globals: globals.node},
},
{plugins: {checkLicensePlugin}},
{
name: 'TypeScript rules',
rules: {
'checkLicensePlugin/check-license': 'error',
'@local/check-license': 'error',

'no-undef': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
Expand All @@ -38,7 +71,52 @@ export default defineConfig([
ignoreRestArgs: true,
},
],
// This optimizes the dependency tracking for type-only files.
'@typescript-eslint/consistent-type-imports': 'error',
// So type-only exports get elided.
'@typescript-eslint/consistent-type-exports': 'error',
// Prefer interfaces over types for shape like.
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/array-type': [
'error',
{
default: 'array-simple',
},
],
'@typescript-eslint/no-floating-promises': 'error',

'import/order': [
'error',
{
'newlines-between': 'always',

alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],

'import/no-cycle': [
'error',
{
maxDepth: Infinity,
},
],

'import/enforce-node-protocol-usage': ['error', 'always'],

'@stylistic/function-call-spacing': 'error',
'@stylistic/semi': 'error',
},
},
{
name: 'Tests',
files: ['**/*.test.ts'],
rules: {
// With the Node.js test runner, `describe` and `it` are technically
// promises, but we don't need to await them.
'@typescript-eslint/no-floating-promises': 'off',
},
},
tseslint.configs.recommended,
]);
Loading
Loading