@@ -65,6 +65,7 @@ import (
6565 "github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/only_throw_error"
6666 "github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/prefer_as_const"
6767 "github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/prefer_promise_reject_errors"
68+
6869 // "github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/prefer_readonly_parameter_types" // Temporarily disabled - incomplete implementation
6970 "github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/prefer_reduce_type_parameter"
7071 "github.com/web-infra-dev/rslint/internal/plugins/typescript/rules/prefer_return_this_type"
@@ -306,47 +307,46 @@ func (config RslintConfig) GetRulesForFile(filePath string) map[string]*RuleConf
306307
307308 for _ , entry := range config {
308309 // First check if the file should be ignored
309- if isFileIgnored (filePath , entry .Ignores ) {
310+ if isFileMatched (filePath , entry .Ignores ) {
310311 continue // Skip this config entry for ignored files
311312 }
312313
313- // Check if the file matches the files pattern
314- matches := true
315-
316- if matches {
314+ // Skip this config entry if the file doesn't matches the files pattern
315+ if len ( entry . Files ) > 0 && ! isFileMatched ( filePath , entry . Files ) {
316+ continue
317+ }
317318
318- /// Merge rules from plugin
319- for _ , plugin := range entry .Plugins {
319+ /// Merge rules from plugin
320+ for _ , plugin := range entry .Plugins {
320321
321- for _ , rule := range GetAllRulesForPlugin (plugin ) {
322- enabledRules [rule .Name ] = & RuleConfig {Level : "error" } // Default level for plugin rules
323- }
322+ for _ , rule := range GetAllRulesForPlugin (plugin ) {
323+ enabledRules [rule .Name ] = & RuleConfig {Level : "error" } // Default level for plugin rules
324324 }
325- // Merge rules from this entry
326- for ruleName , ruleValue := range entry . Rules {
327-
328- switch v := ruleValue .( type ) {
329- case string :
330- // Handle simple string values like "error", "warn", "off"
331- enabledRules [ ruleName ] = & RuleConfig { Level : v }
332- case map [ string ] interface {}:
333- // Handle object configuration
334- ruleConfig := & RuleConfig {}
335- if level , ok := v [ "level" ].( string ); ok {
336- ruleConfig . Level = level
337- }
338- if options , ok := v [ "options" ].( map [ string ] interface {}); ok {
339- ruleConfig . Options = options
340- }
341- if ruleConfig . IsEnabled () {
342- enabledRules [ ruleName ] = ruleConfig
343- }
344- case [] interface {}:
345- // Handle array format like ["error", {...options}] or ["warn"] or ["off"]
346- ruleConfig := parseArrayRuleConfig ( v )
347- if ruleConfig != nil && ruleConfig . IsEnabled () {
348- enabledRules [ ruleName ] = ruleConfig
349- }
325+ }
326+ // Merge rules from this entry
327+ for ruleName , ruleValue := range entry . Rules {
328+
329+ switch v := ruleValue .( type ) {
330+ case string :
331+ // Handle simple string values like "error", "warn", "off"
332+ enabledRules [ ruleName ] = & RuleConfig { Level : v }
333+ case map [ string ] interface {}:
334+ // Handle object configuration
335+ ruleConfig := & RuleConfig {}
336+ if level , ok := v [ " level" ].( string ); ok {
337+ ruleConfig . Level = level
338+ }
339+ if options , ok := v [ " options" ].( map [ string ] interface {}); ok {
340+ ruleConfig . Options = options
341+ }
342+ if ruleConfig . IsEnabled () {
343+ enabledRules [ ruleName ] = ruleConfig
344+ }
345+ case [] interface {}:
346+ // Handle array format like ["error", {...options}] or ["warn"] or ["off"]
347+ ruleConfig := parseArrayRuleConfig ( v )
348+ if ruleConfig != nil && ruleConfig . IsEnabled () {
349+ enabledRules [ ruleName ] = ruleConfig
350350 }
351351 }
352352 }
@@ -471,13 +471,13 @@ func getAllTypeScriptEslintPluginRules() []rule.Rule {
471471 return rules
472472}
473473
474- // isFileIgnored checks if a file should be ignored based on ignore patterns
475- func isFileIgnored (filePath string , ignorePatterns []string ) bool {
474+ // isFileMatched checks if a file should be matched based on glob patterns
475+ func isFileMatched (filePath string , ignorePatterns []string ) bool {
476476 // Get current working directory for relative path resolution
477477 cwd , err := os .Getwd ()
478478 if err != nil {
479479 // If we can't get cwd, fall back to simple matching
480- return isFileIgnoredSimple (filePath , ignorePatterns )
480+ return isFileMatchedSimple (filePath , ignorePatterns )
481481 }
482482
483483 // Normalize the file path relative to cwd
@@ -515,8 +515,8 @@ func normalizePath(filePath, cwd string) string {
515515 }))
516516}
517517
518- // isFileIgnoredSimple provides fallback matching when cwd is unavailable
519- func isFileIgnoredSimple (filePath string , ignorePatterns []string ) bool {
518+ // isFileMatchedSimple provides fallback matching when cwd is unavailable
519+ func isFileMatchedSimple (filePath string , ignorePatterns []string ) bool {
520520 for _ , pattern := range ignorePatterns {
521521 if matched , err := doublestar .Match (pattern , filePath ); err == nil && matched {
522522 return true
0 commit comments