usabilla / fnlint

Lint file name formatting
MIT License
7 stars 2 forks source link

exclude globs #17

Open tomdavidson opened 7 years ago

tomdavidson commented 7 years ago

I am wanting to stitch from name-lint to fnlint, but I am not seeing the option of excluding files. Is this feature available but not documented?

pietvanzoen commented 7 years ago

Hey Tom. We use glob for the files property pattern. A run down of the format is here: https://github.com/isaacs/node-glob#glob-primer

It includes excluding files. But I can see how having a dedicated excludeFiles pattern/array would be useful. We'll look into that.

In the meantime I hope maybe the glob pattern will work for you.

tomdavidson commented 7 years ago

Thank you. I did not realize I could combine excludes with glob. Here is an example of a fnlint.json that is suppose to lint everything except a few md files - incase someone else comes looking:

{
  "basePath": ".",
  "files": "!(.github|.gitlab|CHANGELOG.md|README.md|CONTRIBUTING.md|node_modules)",
  "format": "kebabcase",
  "directories": true
}
tomdavidson commented 7 years ago

Shoot. It did not fail, but also did not when it was suppose to on SNAKE_CASE.md.

{
  "basePath": ".",
  "files": "!(.github|.gitlab|CHANGELOG.md|README.md|CONTRIBUTING.md|node_modules)",
  "format": "kebabcase",
  "directories": true
}
├── CHANGELOG.md
├── common
├── other
│   ├── fnlint.json
│   ├── lower-case-dash.js
│   ├── only-on-master.sh
│   ├── runners
│   │   └── aio
│   │       └── Dockerfile
│   ├── SNAKE_CASE.md
│   └── tf-lint.sh
├── package.json
└── README.md

$ fnlint -c other/fnlint.json 
fnlint kebabcase pass: 2 file(s) linted
pietvanzoen commented 7 years ago

Hey Tom... sorry for the delayed reply.

Looks like the pattern you have is only finding 2 files. I think if you update your "files" pattern to something like the following I think you'll get the results you're after:

!(.github|.gitlab|CHANGELOG.md|README.md|CONTRIBUTING.md|node_modules)**/*
tomdavidson commented 7 years ago

Awesome. Thank you. I was able to dict my custom script today. Thank you for your help and for this tool.

!(.github|.gitlab|CHANGELOG.md|README.md|CONTRIBUTING.md|node_modules)|**/*

tomdavidson commented 7 years ago

always passes: !(.github|.gitlab|CHANGELOG.md|README.md|CONTRIBUTING.md|node_modules)|*/

does not lint '.' - basePath is '.' "!(.github|.gitlab|CHANGELOG.md|README.md|CONTRIBUTING.md|node_modules)*/"

does not lint subdirectories "!(.github|.gitlab|CHANGELOG.md|README.md|CONTRIBUTING.md|node_modules)**",

I am not following how commander and the rest works, I think fnlint needs a PR that makes an exclude option to node-glob's ignore.