axetroy / axetroy/fslint

重新设计规则文件

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
5
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### New1

```jsonc
{
"fileRules": {
"allowedExtensions": [".js", ".ts", ".jsx", ".tsx", ".json"], // 允许的文件扩展名
"case": "camelCase", // 文件名的命名风格,可以是 camelCase、snake_case、PascalCase、kebab-case 等
"prefixes": ["use", "get", "set"], // 文件名允许的前缀
"suffixes": ["Service", "Controller"], // 文件名允许的后缀
"minLength": 3, // 文件名的最小长度
"maxLength": 30, // 文件名的最大长度
"disallowedPatterns": ["temp", "backup"], // 不允许出现在文件名中的字符串或模式
"customPatterns": { // 定义自定义的正则表达式规则
"noSpaces": "^[^\\s]+$", // 禁止文件名中包含空格
"noSpecialChars": "^[a-zA-Z0-9_-]+$" // 文件名只能包含字母、数字、下划线和连字符
}
},
"directoryRules": {
"case": "kebab-case", // 目录名的命名风格,可以是 camelCase、snake_case、PascalCase、kebab-case 等
"allowedPatterns": ["^[a-z]+$", "^[0-9]+$"], // 允许的目录名模式,可以是正则表达式
"disallowedNames": ["node_modules", "dist", "build"], // 不允许的目录名称
"maxDepth": 5 // 目录的最大嵌套深度
},
"ignore": [
"**/node_modules/**", // 忽略的目录或文件路径模式
"**/dist/**",
"**/*.min.js"
]
}
```

### New 2

```jsonc
{
"rules": [
{
"patterns": ["src/components/**"],
"fileRules": {
"allowedExtensions": [".js", ".jsx"],
"case": "PascalCase",
"suffixes": ["Component"],
"minLength": 3,
"maxLength": 40
},
"directoryRules": {
"case": "kebab-case",
"maxDepth": 3
}
},
{
"patterns": ["src/utils/**"],
"fileRules": {
"allowedExtensions": [".js", ".ts"],
"case": "camelCase",
"prefixes": ["is", "has", "get", "set"],
"disallowedPatterns": ["temp", "test"],
"minLength": 5,
"maxLength": 50
},
"directoryRules": {
"case": "kebab-case"
}
},
{
"patterns": ["test/**"],
"fileRules": {
"allowedExtensions": [".spec.js", ".test.js"],
"case": "snake_case",
"suffixes": ["spec", "test"],
"minLength": 5,
"maxLength": 60
},
"directoryRules": {
"case": "snake_case"
}
}
],
"globalIgnore": [
"**/node_modules/**",
"**/dist/**",
"**/*.min.js"
]
}
```

### New 3

```jsonc
{
"rules": [
{
"condition": {
"pathMatches": "src/components/**",
"extension": ".jsx",
"depthLessThan": 3
},
"fileRules": {
"case": "PascalCase",
"suffix": "Component"
}
},
{
"condition": {
"pathMatches": "src/services/**",
"extension": ".js",
"fileNameContains": ["Service"]
},
"fileRules": {
"case": "camelCase",
"prefix": "use",
"maxLength": 30
}
},
{
"condition": {
"pathMatches": "test/**",
"extension": [".test.js", ".spec.js"],
"nameMatches": "^[a-z_]+$"
},
"fileRules": {
"case": "snake_case",
"suffix": ["test", "spec"]
}
},
{
"condition": {
"pathContains": "legacy",
"fileType": "directory"
},
"directoryRules": {
"case": "kebab-case",
"maxDepth": 5
}
},
{
"condition": {
"pathMatches": "**/*.config.js"
},
"fileRules": {
"case": "kebab-case",
"maxLength": 40
}
}
],
"globalRules": {
"ignorePatterns": [
"**/node_modules/**",
"**/dist/**"
]
}
}
```

### New 4

```jsonc
{
"defaultRules": {
"fileRules": {
"case": "kebab-case",
"minLength": 3,
"maxLength": 30,
"allowedExtensions": [".js", ".ts", ".json"]
},
"directoryRules": {
"case": "kebab-case"
}
},
"overrides": [
{
"patterns": ["src/components/**"],
"priority": 1,
"fileRules": {
"case": "PascalCase",
"suffixes": ["Component"],
"allowedExtensions": [".js", ".jsx"]
}
},
{
"patterns": ["src/utils/**"],
"priority": 2,
"fileRules": {
"case": "camelCase",
"prefixes": ["get", "set", "is"],
"allowedExtensions": [".js", ".ts"],
"disallowedPatterns": ["temp", "test"]
}
},
{
"patterns": ["test/**"],
"priority": 3,
"fileRules": {
"case": "snake_case",
"suffixes": ["test", "spec"],
"allowedExtensions": [".test.js", ".spec.js"]
},
"directoryRules": {
"case": "snake_case"
}
}
],
"ignore": [
"**/node_modules/**",
"**/dist/**"
]
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue presents four alternative rule-file schemas but names no files, tests, or selected design. First inspect the repository's configuration and rule-parsing entry points and determine which schema is accepted; done requires an agreed design implemented with validation and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.