Skip to content

Commit 94d6220

Browse files
committed
feat: use .ls-lint.yaml file as default configuration file
The .ls-lint.yaml file is now used as the default configuration file The .ls-lint.yml file is still supported for backward compatibility. The choice was made to prioritize the .ls-lint.yaml file for its clarity and alignment with YAML file naming conventions.
1 parent ed549ee commit 94d6220

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ An extremely fast directory and filename linter - Bring some structure to your p
1111
![npm](https://badgen.net/static/npm%20downloads%20total/9M+/green)
1212
<a href="https://www.npmjs.com/package/@ls-lint/ls-lint"><img src="https://img.shields.io/npm/l/@ls-lint/ls-lint.svg?sanitize=true" alt="License"></a>
1313

14-
- Minimal setup with simple rules managed in one single or multiple `.ls-lint.yml` files
15-
- Works for directory and file names - all extensions supported - full unicode support
14+
- Minimal setup with simple rules managed in one single or multiple `.ls-lint.yaml` (or `.ls-lint.yml`) files
15+
- Works for directory and file names - all extensions supported - full Unicode support
1616
- Incredibly fast - lints thousands of files and directories in milliseconds
1717
- Support for Windows, MacOS and Linux + [NPM Package](https://www.npmjs.com/package/@ls-lint/ls-lint) + [GitHub Action](https://github.com/ls-lint/action) + [Homebrew](https://formulae.brew.sh/formula/ls-lint) + Docker
1818
- Trusted by [Renovate](https://github.com/renovatebot/renovate/blob/main/.ls-lint.yml), [Terser](https://github.com/terser/terser/blob/master/.ls-lint.yml) and many more
@@ -34,7 +34,7 @@ The full documentation can be found at [ls-lint.org](https://ls-lint.org)
3434

3535
## Demo
3636

37-
### Configuration `.ls-lint.yml`
37+
### Configuration `.ls-lint.yaml`
3838

3939
```yaml
4040
ls:

cmd/ls_lint/main.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,24 @@ import (
1111
"slices"
1212
"strings"
1313

14+
"gopkg.in/yaml.v3"
15+
1416
"github.com/loeffel-io/ls-lint/v2/internal/config"
1517
"github.com/loeffel-io/ls-lint/v2/internal/debug"
1618
_flag "github.com/loeffel-io/ls-lint/v2/internal/flag"
1719
"github.com/loeffel-io/ls-lint/v2/internal/linter"
1820
"github.com/loeffel-io/ls-lint/v2/internal/rule"
19-
"gopkg.in/yaml.v3"
2021
)
2122

2223
var Version = "dev"
2324

25+
const (
26+
// expected ls-lint config file
27+
lsLintConfigFile = ".ls-lint.yaml"
28+
// former ls-lint config file, supported for backward compatibility
29+
lsLintConfigFileLegacy = ".ls-lint.yml"
30+
)
31+
2432
func main() {
2533
var err error
2634
exitCode := 0
@@ -57,7 +65,15 @@ func main() {
5765
}
5866

5967
if len(flagConfig) == 0 {
60-
flagConfig = _flag.Config{".ls-lint.yml"}
68+
// no config files was provided by the --config flag
69+
70+
// We try the .yaml file first
71+
configFile := lsLintConfigFile
72+
if _, err := os.Stat(lsLintConfigFileLegacy); err == nil {
73+
// but we use the .yml one if it exists
74+
configFile = lsLintConfigFileLegacy
75+
}
76+
flagConfig = _flag.Config{configFile}
6177
}
6278

6379
filesystem := os.DirFS(*flagWorkdir)

0 commit comments

Comments
 (0)