Skip to content

Commit dff4dc9

Browse files
authored
Filename-format rule: fix filename extension regex: ".go" to "\\.go". (#1132)
1 parent 660968f commit dff4dc9

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

RULES_DESCRIPTIONS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,15 @@ Example:
521521
```
522522

523523
## filename-format
524-
_Description_: enforces conventions on source file names. By default, the rule enforces filenames of the form `^[_A-Za-z0-9][_A-Za-z0-9-]*.go$`: Optionally, the rule can be configured to enforce other forms.
524+
_Description_: enforces conventions on source file names. By default, the rule enforces filenames of the form `^[_A-Za-z0-9][_A-Za-z0-9-]*\.go$`: Optionally, the rule can be configured to enforce other forms.
525525

526526
_Configuration_: (string) regular expression for source filenames.
527527

528528
Example:
529529

530530
```toml
531531
[rule.filename-format]
532-
arguments=["^[_a-z][_a-z0-9]*.go$"]
532+
arguments=["^[_a-z][_a-z0-9]*\\.go$"]
533533
```
534534

535535
## flag-parameter

revive.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ warningCode = 1
2121
[rule.exported]
2222
[rule.filename-format]
2323
# Override the default pattern to forbid .go files with uppercase letters and dashes.
24-
arguments=["^[_a-z][_a-z0-9]*.go$"]
24+
arguments=["^[_a-z][_a-z0-9]*\\.go$"]
2525
[rule.increment-decrement]
2626
[rule.indent-error-flow]
2727
[rule.line-length-limit]

rule/filename_format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (*FilenameFormatRule) Name() string {
5353
return "filename-format"
5454
}
5555

56-
var defaultFormat = regexp.MustCompile("^[_A-Za-z0-9][_A-Za-z0-9-]*.go$")
56+
var defaultFormat = regexp.MustCompile(`^[_A-Za-z0-9][_A-Za-z0-9-]*\.go$`)
5757

5858
func (r *FilenameFormatRule) configure(arguments lint.Arguments) {
5959
argsCount := len(arguments)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package main
22

3-
// MATCH:1 /Filename filenamе_with_non_ascii_char.go is not of the format ^[_A-Za-z0-9][_A-Za-z0-9-]*.go$. Non ASCII character е (U+0435) found./
3+
// MATCH:1 /Filename filenamе_with_non_ascii_char.go is not of the format ^[_A-Za-z0-9][_A-Za-z0-9-]*\.go$. Non ASCII character е (U+0435) found./

0 commit comments

Comments
 (0)