Refactor ESLint config for improved readability
Reformatted the ESLint configuration file to use consistent array/object formatting and removed unnecessary quotes from rule names. No functional changes were made; this improves maintainability and clarity. Other config files had only minor formatting updates.
This commit is contained in:
1 parent
782fb3492d
commit
78ebc49a4b
7 files changed
+5062
-5038
No files matched your search
+1
-1
@@ -37,4 +37,4 @@
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": false
|
||||
}
|
||||
}
|
||||
+126
-74
@@ -19,7 +19,7 @@ export default [
|
||||
URL: 'readonly',
|
||||
URLSearchParams: 'readonly',
|
||||
console: 'readonly',
|
||||
|
||||
|
||||
// Vitest globals
|
||||
describe: 'readonly',
|
||||
it: 'readonly',
|
||||
@@ -33,19 +33,25 @@ export default [
|
||||
},
|
||||
rules: {
|
||||
// Code quality rules
|
||||
'no-unused-vars': ['error', {
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_'
|
||||
}],
|
||||
'no-console': ['warn', {
|
||||
allow: ['warn', 'error']
|
||||
}],
|
||||
'no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_'
|
||||
}
|
||||
],
|
||||
'no-console': [
|
||||
'warn',
|
||||
{
|
||||
allow: ['warn', 'error']
|
||||
}
|
||||
],
|
||||
'no-debugger': 'error',
|
||||
'no-alert': 'error',
|
||||
|
||||
|
||||
// Best practices
|
||||
'eqeqeq': ['error', 'always'],
|
||||
'curly': ['error', 'all'],
|
||||
eqeqeq: ['error', 'always'],
|
||||
curly: ['error', 'all'],
|
||||
'no-eval': 'error',
|
||||
'no-implied-eval': 'error',
|
||||
'no-new-func': 'error',
|
||||
@@ -59,9 +65,9 @@ export default [
|
||||
'no-useless-concat': 'error',
|
||||
'no-useless-return': 'error',
|
||||
'prefer-promise-reject-errors': 'error',
|
||||
'radix': 'error',
|
||||
'yoda': 'error',
|
||||
|
||||
radix: 'error',
|
||||
yoda: 'error',
|
||||
|
||||
// Variables
|
||||
'no-delete-var': 'error',
|
||||
'no-label-var': 'error',
|
||||
@@ -70,74 +76,116 @@ export default [
|
||||
'no-shadow-restricted-names': 'error',
|
||||
'no-undef': 'error',
|
||||
'no-undef-init': 'error',
|
||||
'no-use-before-define': ['error', {
|
||||
functions: false,
|
||||
classes: true,
|
||||
variables: true
|
||||
}],
|
||||
|
||||
'no-use-before-define': [
|
||||
'error',
|
||||
{
|
||||
functions: false,
|
||||
classes: true,
|
||||
variables: true
|
||||
}
|
||||
],
|
||||
|
||||
// Stylistic issues
|
||||
'array-bracket-spacing': ['error', 'never'],
|
||||
'block-spacing': ['error', 'always'],
|
||||
'brace-style': ['error', '1tbs', {
|
||||
allowSingleLine: true
|
||||
}],
|
||||
'camelcase': ['error', {
|
||||
properties: 'never'
|
||||
}],
|
||||
'brace-style': [
|
||||
'error',
|
||||
'1tbs',
|
||||
{
|
||||
allowSingleLine: true
|
||||
}
|
||||
],
|
||||
camelcase: [
|
||||
'error',
|
||||
{
|
||||
properties: 'never'
|
||||
}
|
||||
],
|
||||
'comma-dangle': ['error', 'never'],
|
||||
'comma-spacing': ['error', {
|
||||
before: false,
|
||||
after: true
|
||||
}],
|
||||
'comma-spacing': [
|
||||
'error',
|
||||
{
|
||||
before: false,
|
||||
after: true
|
||||
}
|
||||
],
|
||||
'comma-style': ['error', 'last'],
|
||||
'computed-property-spacing': ['error', 'never'],
|
||||
'eol-last': ['error', 'always'],
|
||||
'func-call-spacing': ['error', 'never'],
|
||||
'indent': ['error', 2, {
|
||||
SwitchCase: 1
|
||||
}],
|
||||
'key-spacing': ['error', {
|
||||
beforeColon: false,
|
||||
afterColon: true
|
||||
}],
|
||||
'keyword-spacing': ['error', {
|
||||
before: true,
|
||||
after: true
|
||||
}],
|
||||
indent: [
|
||||
'error',
|
||||
2,
|
||||
{
|
||||
SwitchCase: 1
|
||||
}
|
||||
],
|
||||
'key-spacing': [
|
||||
'error',
|
||||
{
|
||||
beforeColon: false,
|
||||
afterColon: true
|
||||
}
|
||||
],
|
||||
'keyword-spacing': [
|
||||
'error',
|
||||
{
|
||||
before: true,
|
||||
after: true
|
||||
}
|
||||
],
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
'no-multiple-empty-lines': ['error', {
|
||||
max: 2,
|
||||
maxEOF: 1
|
||||
}],
|
||||
'no-multiple-empty-lines': [
|
||||
'error',
|
||||
{
|
||||
max: 2,
|
||||
maxEOF: 1
|
||||
}
|
||||
],
|
||||
'no-trailing-spaces': 'error',
|
||||
'object-curly-spacing': ['error', 'always'],
|
||||
'quotes': ['error', 'single', {
|
||||
avoidEscape: true
|
||||
}],
|
||||
'semi': ['error', 'always'],
|
||||
'semi-spacing': ['error', {
|
||||
before: false,
|
||||
after: true
|
||||
}],
|
||||
quotes: [
|
||||
'error',
|
||||
'single',
|
||||
{
|
||||
avoidEscape: true
|
||||
}
|
||||
],
|
||||
semi: ['error', 'always'],
|
||||
'semi-spacing': [
|
||||
'error',
|
||||
{
|
||||
before: false,
|
||||
after: true
|
||||
}
|
||||
],
|
||||
'space-before-blocks': ['error', 'always'],
|
||||
'space-before-function-paren': ['error', {
|
||||
anonymous: 'always',
|
||||
named: 'never',
|
||||
asyncArrow: 'always'
|
||||
}],
|
||||
'space-before-function-paren': [
|
||||
'error',
|
||||
{
|
||||
anonymous: 'always',
|
||||
named: 'never',
|
||||
asyncArrow: 'always'
|
||||
}
|
||||
],
|
||||
'space-in-parens': ['error', 'never'],
|
||||
'space-infix-ops': 'error',
|
||||
'space-unary-ops': ['error', {
|
||||
words: true,
|
||||
nonwords: false
|
||||
}],
|
||||
|
||||
'space-unary-ops': [
|
||||
'error',
|
||||
{
|
||||
words: true,
|
||||
nonwords: false
|
||||
}
|
||||
],
|
||||
|
||||
// ES6+ rules
|
||||
'arrow-spacing': ['error', {
|
||||
before: true,
|
||||
after: true
|
||||
}],
|
||||
'arrow-spacing': [
|
||||
'error',
|
||||
{
|
||||
before: true,
|
||||
after: true
|
||||
}
|
||||
],
|
||||
'constructor-super': 'error',
|
||||
'no-class-assign': 'error',
|
||||
'no-const-assign': 'error',
|
||||
@@ -152,12 +200,16 @@ export default [
|
||||
'object-shorthand': ['error', 'always'],
|
||||
'prefer-arrow-callback': 'error',
|
||||
'prefer-const': 'error',
|
||||
'prefer-destructuring': ['error', {
|
||||
array: true,
|
||||
object: true
|
||||
}, {
|
||||
enforceForRenamedProperties: false
|
||||
}],
|
||||
'prefer-destructuring': [
|
||||
'error',
|
||||
{
|
||||
array: true,
|
||||
object: true
|
||||
},
|
||||
{
|
||||
enforceForRenamedProperties: false
|
||||
}
|
||||
],
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'prefer-template': 'error',
|
||||
@@ -173,4 +225,4 @@ export default [
|
||||
'no-unused-expressions': 'off'
|
||||
}
|
||||
}
|
||||
];
|
||||
];
|
||||
Generated
+4828
-4828
File diff suppressed because it is too large.
Load diff
+30
-30
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"xget": "file:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/vitest-pool-workers": "^0.8.36",
|
||||
"@cloudflare/workers-types": "^4.20250724.0",
|
||||
"eslint": "^9.31.0",
|
||||
"prettier": "^3.6.2",
|
||||
"vitest": "^3.1.4",
|
||||
"wrangler": "^4.26.0"
|
||||
},
|
||||
"name": "xget",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"deploy": "wrangler deploy",
|
||||
"dev": "wrangler dev",
|
||||
"format": "prettier --write src/ test/ *.js *.json *.md",
|
||||
"format:check": "prettier --check src/ test/ *.js *.json *.md",
|
||||
"lint": "eslint src/ test/",
|
||||
"lint:fix": "eslint src/ test/ --fix",
|
||||
"start": "wrangler dev",
|
||||
"test": "vitest",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:run": "vitest run",
|
||||
"test:ui": "vitest --ui",
|
||||
"test:watch": "vitest --watch",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
"dependencies": {
|
||||
"xget": "file:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/vitest-pool-workers": "^0.8.36",
|
||||
"@cloudflare/workers-types": "^4.20250724.0",
|
||||
"eslint": "^9.31.0",
|
||||
"prettier": "^3.6.2",
|
||||
"vitest": "^3.1.4",
|
||||
"wrangler": "^4.26.0"
|
||||
},
|
||||
"name": "xget",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"deploy": "wrangler deploy",
|
||||
"dev": "wrangler dev",
|
||||
"format": "prettier --write src/ test/ *.js *.json *.md",
|
||||
"format:check": "prettier --check src/ test/ *.js *.json *.md",
|
||||
"lint": "eslint src/ test/",
|
||||
"lint:fix": "eslint src/ test/ --fix",
|
||||
"start": "wrangler dev",
|
||||
"test": "vitest",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:run": "vitest run",
|
||||
"test:ui": "vitest --ui",
|
||||
"test:watch": "vitest --watch",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
+45
-60
@@ -77,12 +77,8 @@ async function main() {
|
||||
*/
|
||||
async function runTests(args = []) {
|
||||
console.log('🏃 Running tests...');
|
||||
|
||||
const vitestArgs = [
|
||||
'run',
|
||||
'--config', 'vitest.config.js',
|
||||
...args
|
||||
];
|
||||
|
||||
const vitestArgs = ['run', '--config', 'vitest.config.js', ...args];
|
||||
|
||||
await runCommand('npx', ['vitest', ...vitestArgs]);
|
||||
}
|
||||
@@ -92,12 +88,8 @@ async function runTests(args = []) {
|
||||
*/
|
||||
async function watchTests(args = []) {
|
||||
console.log('👀 Watching tests...');
|
||||
|
||||
const vitestArgs = [
|
||||
'--config', 'vitest.config.js',
|
||||
'--watch',
|
||||
...args
|
||||
];
|
||||
|
||||
const vitestArgs = ['--config', 'vitest.config.js', '--watch', ...args];
|
||||
|
||||
await runCommand('npx', ['vitest', ...vitestArgs]);
|
||||
}
|
||||
@@ -107,18 +99,13 @@ async function watchTests(args = []) {
|
||||
*/
|
||||
async function runCoverage(args = []) {
|
||||
console.log('📊 Generating coverage report...');
|
||||
|
||||
const vitestArgs = [
|
||||
'run',
|
||||
'--config', 'vitest.config.js',
|
||||
'--coverage',
|
||||
...args
|
||||
];
|
||||
|
||||
const vitestArgs = ['run', '--config', 'vitest.config.js', '--coverage', ...args];
|
||||
|
||||
await runCommand('npx', ['vitest', ...vitestArgs]);
|
||||
|
||||
|
||||
console.log('📈 Coverage report generated in ./coverage/');
|
||||
|
||||
|
||||
// Generate coverage summary
|
||||
await generateCoverageSummary();
|
||||
}
|
||||
@@ -128,12 +115,8 @@ async function runCoverage(args = []) {
|
||||
*/
|
||||
async function runBenchmarks(args = []) {
|
||||
console.log('⚡ Running performance benchmarks...');
|
||||
|
||||
const vitestArgs = [
|
||||
'bench',
|
||||
'--config', 'vitest.config.js',
|
||||
...args
|
||||
];
|
||||
|
||||
const vitestArgs = ['bench', '--config', 'vitest.config.js', ...args];
|
||||
|
||||
await runCommand('npx', ['vitest', ...vitestArgs]);
|
||||
}
|
||||
@@ -143,9 +126,9 @@ async function runBenchmarks(args = []) {
|
||||
*/
|
||||
async function runLinting() {
|
||||
console.log('🔍 Running ESLint...');
|
||||
|
||||
|
||||
await runCommand('npx', ['eslint', 'src/', 'test/', '--ext', '.js']);
|
||||
|
||||
|
||||
console.log('✅ Linting completed');
|
||||
}
|
||||
|
||||
@@ -154,9 +137,9 @@ async function runLinting() {
|
||||
*/
|
||||
async function runFormatting() {
|
||||
console.log('💅 Running Prettier...');
|
||||
|
||||
|
||||
await runCommand('npx', ['prettier', '--write', 'src/', 'test/', '*.js', '*.json', '*.md']);
|
||||
|
||||
|
||||
console.log('✅ Formatting completed');
|
||||
}
|
||||
|
||||
@@ -165,20 +148,20 @@ async function runFormatting() {
|
||||
*/
|
||||
async function runCITests() {
|
||||
console.log('🤖 Running CI test suite...');
|
||||
|
||||
|
||||
// Run linting
|
||||
await runLinting();
|
||||
|
||||
|
||||
// Check formatting
|
||||
console.log('📝 Checking code formatting...');
|
||||
await runCommand('npx', ['prettier', '--check', 'src/', 'test/', '*.js', '*.json', '*.md']);
|
||||
|
||||
|
||||
// Run tests with coverage
|
||||
await runCoverage(['--reporter=json', '--reporter=text']);
|
||||
|
||||
|
||||
// Run benchmarks
|
||||
await runBenchmarks(['--reporter=json']);
|
||||
|
||||
|
||||
console.log('✅ CI test suite completed');
|
||||
}
|
||||
|
||||
@@ -187,7 +170,7 @@ async function runCITests() {
|
||||
*/
|
||||
async function setupTestEnvironment() {
|
||||
console.log('🔧 Setting up test environment...');
|
||||
|
||||
|
||||
// Create necessary directories
|
||||
const dirs = ['coverage', 'test/tmp', 'test/logs'];
|
||||
dirs.forEach(dir => {
|
||||
@@ -197,19 +180,16 @@ async function setupTestEnvironment() {
|
||||
console.log(`📁 Created directory: ${dir}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Create test configuration file
|
||||
const testConfig = {
|
||||
...TEST_CONFIG,
|
||||
timestamp: new Date().toISOString(),
|
||||
version: process.env.npm_package_version || '1.0.0'
|
||||
};
|
||||
|
||||
writeFileSync(
|
||||
join(rootDir, 'test/config.json'),
|
||||
JSON.stringify(testConfig, null, 2)
|
||||
);
|
||||
|
||||
|
||||
writeFileSync(join(rootDir, 'test/config.json'), JSON.stringify(testConfig, null, 2));
|
||||
|
||||
console.log('✅ Test environment setup completed');
|
||||
}
|
||||
|
||||
@@ -218,10 +198,10 @@ async function setupTestEnvironment() {
|
||||
*/
|
||||
async function cleanTestArtifacts() {
|
||||
console.log('🧹 Cleaning test artifacts...');
|
||||
|
||||
|
||||
const { rmSync } = await import('fs');
|
||||
const artifactDirs = ['coverage', 'test/tmp', 'test/logs'];
|
||||
|
||||
|
||||
artifactDirs.forEach(dir => {
|
||||
const fullPath = join(rootDir, dir);
|
||||
if (existsSync(fullPath)) {
|
||||
@@ -229,7 +209,7 @@ async function cleanTestArtifacts() {
|
||||
console.log(`🗑️ Removed: ${dir}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
console.log('✅ Cleanup completed');
|
||||
}
|
||||
|
||||
@@ -238,20 +218,26 @@ async function cleanTestArtifacts() {
|
||||
*/
|
||||
async function generateCoverageSummary() {
|
||||
const coverageFile = join(rootDir, 'coverage/coverage-summary.json');
|
||||
|
||||
|
||||
if (existsSync(coverageFile)) {
|
||||
const { readFileSync } = await import('fs');
|
||||
const coverage = JSON.parse(readFileSync(coverageFile, 'utf8'));
|
||||
|
||||
|
||||
console.log('\n📊 Coverage Summary:');
|
||||
console.log('===================');
|
||||
|
||||
|
||||
const total = coverage.total;
|
||||
console.log(`Lines: ${total.lines.pct}% (${total.lines.covered}/${total.lines.total})`);
|
||||
console.log(`Functions: ${total.functions.pct}% (${total.functions.covered}/${total.functions.total})`);
|
||||
console.log(`Branches: ${total.branches.pct}% (${total.branches.covered}/${total.branches.total})`);
|
||||
console.log(`Statements: ${total.statements.pct}% (${total.statements.covered}/${total.statements.total})`);
|
||||
|
||||
console.log(
|
||||
`Functions: ${total.functions.pct}% (${total.functions.covered}/${total.functions.total})`
|
||||
);
|
||||
console.log(
|
||||
`Branches: ${total.branches.pct}% (${total.branches.covered}/${total.branches.total})`
|
||||
);
|
||||
console.log(
|
||||
`Statements: ${total.statements.pct}% (${total.statements.covered}/${total.statements.total})`
|
||||
);
|
||||
|
||||
// Check if coverage meets threshold
|
||||
const threshold = TEST_CONFIG.coverage.threshold;
|
||||
const meetsThreshold = [
|
||||
@@ -260,7 +246,7 @@ async function generateCoverageSummary() {
|
||||
total.branches.pct >= threshold,
|
||||
total.statements.pct >= threshold
|
||||
].every(Boolean);
|
||||
|
||||
|
||||
if (meetsThreshold) {
|
||||
console.log(`\n✅ Coverage meets threshold (${threshold}%)`);
|
||||
} else {
|
||||
@@ -279,16 +265,16 @@ function runCommand(command, args = [], options = {}) {
|
||||
cwd: rootDir,
|
||||
...options
|
||||
});
|
||||
|
||||
child.on('close', (code) => {
|
||||
|
||||
child.on('close', code => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(`Command failed with exit code ${code}`));
|
||||
}
|
||||
});
|
||||
|
||||
child.on('error', (error) => {
|
||||
|
||||
child.on('error', error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
@@ -332,4 +318,3 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
}
|
||||
|
||||
export { main, runBenchmarks, runCoverage, runTests };
|
||||
|
||||
+16
-26
@@ -1,27 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"target": "ES2022",
|
||||
"types": [
|
||||
"@cloudflare/workers-types",
|
||||
"vitest/globals"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"coverage"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"test/**/*"
|
||||
]
|
||||
}
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"target": "ES2022",
|
||||
"types": ["@cloudflare/workers-types", "vitest/globals"]
|
||||
},
|
||||
"exclude": ["node_modules", "dist", "coverage"],
|
||||
"include": ["src/**/*", "test/**/*"]
|
||||
}
|
||||
+16
-19
@@ -1,36 +1,33 @@
|
||||
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
|
||||
import { defineWorkersConfig } from "@cloudflare/vitest-pool-workers/config";
|
||||
|
||||
export default defineWorkersConfig({
|
||||
test: {
|
||||
poolOptions: {
|
||||
workers: {
|
||||
wrangler: { configPath: './wrangler.toml' },
|
||||
wrangler: { configPath: "./wrangler.toml" },
|
||||
},
|
||||
},
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
reporter: ['text', 'json', 'html', 'lcov'],
|
||||
reportsDirectory: './coverage',
|
||||
provider: "v8",
|
||||
reporter: ["text", "json", "html", "lcov"],
|
||||
reportsDirectory: "./coverage",
|
||||
exclude: [
|
||||
'node_modules/**',
|
||||
'test/**',
|
||||
'coverage/**',
|
||||
'dist/**',
|
||||
'*.config.js',
|
||||
'*.config.ts'
|
||||
],
|
||||
include: [
|
||||
'src/**/*.js',
|
||||
'src/**/*.ts'
|
||||
"node_modules/**",
|
||||
"test/**",
|
||||
"coverage/**",
|
||||
"dist/**",
|
||||
"*.config.js",
|
||||
"*.config.ts",
|
||||
],
|
||||
include: ["src/**/*.js", "src/**/*.ts"],
|
||||
thresholds: {
|
||||
global: {
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80
|
||||
}
|
||||
}
|
||||
}
|
||||
statements: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user