Skip to content

Commit

Permalink
Filename-format rule: fix filename extension regex: ".go" to "\\.go". (
Browse files Browse the repository at this point in the history
  • Loading branch information
denarced authored Nov 16, 2024
1 parent 660968f commit dff4dc9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions RULES_DESCRIPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,15 @@ Example:
```

## filename-format
_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.
_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.

_Configuration_: (string) regular expression for source filenames.

Example:

```toml
[rule.filename-format]
arguments=["^[_a-z][_a-z0-9]*.go$"]
arguments=["^[_a-z][_a-z0-9]*\\.go$"]
```

## flag-parameter
Expand Down
2 changes: 1 addition & 1 deletion revive.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ warningCode = 1
[rule.exported]
[rule.filename-format]
# Override the default pattern to forbid .go files with uppercase letters and dashes.
arguments=["^[_a-z][_a-z0-9]*.go$"]
arguments=["^[_a-z][_a-z0-9]*\\.go$"]
[rule.increment-decrement]
[rule.indent-error-flow]
[rule.line-length-limit]
Expand Down
2 changes: 1 addition & 1 deletion rule/filename_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (*FilenameFormatRule) Name() string {
return "filename-format"
}

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

func (r *FilenameFormatRule) configure(arguments lint.Arguments) {
argsCount := len(arguments)
Expand Down
2 changes: 1 addition & 1 deletion testdata/filenamе_with_non_ascii_char.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

// 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./
// 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 comments on commit dff4dc9

Please sign in to comment.