frontend/config/eslint-config/README.md
A comprehensive ESLint configuration package for the Coze architecture ecosystem, providing standardized linting rules for JavaScript, TypeScript, React, and Node.js projects.
# Install the package
pnpm add @coze-arch/eslint-config --save-dev
# Update workspace dependencies
rush update
Create an eslint.config.js file in your project root:
const { defineConfig } = require('@coze-arch/eslint-config');
module.exports = defineConfig({
packageRoot: __dirname,
preset: 'web', // or 'node' or 'base'
});
defineConfig(config)The main function to create ESLint configurations.
config (EnhanceESLintConfig): Configuration objectinterface EnhanceESLintConfig extends ESLintConfig {
/**
* Project root directory
*/
packageRoot: string;
/**
* Configuration preset mode
*/
preset: 'web' | 'node' | 'base';
/**
* Additional configuration overrides
*/
overrides?: ESLintConfig[];
/**
* Custom ignore patterns
*/
ignores?: string[];
/**
* Custom rules
*/
rules?: Linter.RulesRecord;
/**
* ESLint settings
*/
settings?: any;
}
preset: 'web')Optimized for React web applications:
module.exports = defineConfig({
packageRoot: __dirname,
preset: 'web',
});
Includes:
eslint-plugin-risxsspreset: 'node')Optimized for Node.js applications:
module.exports = defineConfig({
packageRoot: __dirname,
preset: 'node',
});
Includes:
preset: 'base')Minimal configuration for libraries:
module.exports = defineConfig({
packageRoot: __dirname,
preset: 'base',
});
Includes:
module.exports = defineConfig({
packageRoot: __dirname,
preset: 'web',
rules: {
'no-console': 'warn',
'@typescript-eslint/no-unused-vars': 'error',
},
});
module.exports = defineConfig({
packageRoot: __dirname,
preset: 'web',
overrides: [
{
files: ['**/*.test.ts', '**/*.spec.ts'],
rules: {
'max-lines': 'off',
},
},
],
});
module.exports = defineConfig({
packageRoot: __dirname,
preset: 'web',
ignores: [
'custom-build/**',
'temp/**',
],
});
The package provides convenient CLI scripts:
# Using the built-in eslint script
npx eslint ./src
# Using the reslint alias
npx reslint ./src
# Format code with Prettier
npx prettier --write ./src
config/eslint-config/
โโโ src/
โ โโโ index.js # Main entry point
โ โโโ define-config.ts # Configuration function
โโโ rules/ # Rule configurations
โ โโโ common-standard.js # Common rules
โ โโโ import.js # Import rules
โ โโโ js-standard.js # JavaScript rules
โ โโโ ts-standard.js # TypeScript rules
โ โโโ test-standard.js # Test file rules
โโโ scripts/
โ โโโ reslint.sh # ESLint wrapper script
โ โโโ rprettier.sh # Prettier wrapper script
โโโ eslint.config.base.js # Base configuration
โโโ eslint.config.web.js # Web configuration
โโโ eslint.config.node.js # Node.js configuration
โโโ package.json
# Build the package
rush build --to @coze-arch/eslint-config
# Run linting
rush lint --to @coze-arch/eslint-config
# Run tests
rush test --to @coze-arch/eslint-config
Internal package for Coze architecture ecosystem.
For more information about ESLint configuration, visit the ESLint documentation.