Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stscoundrel/alliser
Detect & list not-allowed file extensions in a project
https://github.com/stscoundrel/alliser
alliser cli extensions filetype-validator typescript utility
Last synced: 13 days ago
JSON representation
Detect & list not-allowed file extensions in a project
- Host: GitHub
- URL: https://github.com/stscoundrel/alliser
- Owner: stscoundrel
- License: mit
- Created: 2022-01-07T07:35:47.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-25T06:33:15.000Z (6 months ago)
- Last Synced: 2024-09-15T22:21:00.602Z (about 2 months ago)
- Topics: alliser, cli, extensions, filetype-validator, typescript, utility
- Language: TypeScript
- Homepage:
- Size: 966 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Alliser
Detect & list not allowed file extensions in a project. Scans project & compares findings against list of allowed filetypes.
Also available for your CI as batteries included [Github Action](https://github.com/marketplace/actions/alliser-action).
### Install
`yarn add alliser`
### Motivation
In some project setups, one can use incorrect file extension without actually breaking the project. An example of this would be a TypeScript project, where one accidentally writes Jest test-files in .js instead of .ts. Jest allows that, and project gets randomly littered with .js files that do work. Or maybe you just want to let team members know, that a particular filetype or programming language is discouraged.
Alliser goes through files, and lets you know if you have non-allowed file types within the project.
#### Wait, can't I do this with gitignore?
Depending on your use case, you might! There are differences though.
Gitignore is commonly used for completely blocking something from your repo. Things in there are artifacts you _dont want_ in repo, maybe dist, builds or external deps. Things that Alliser checks are things you _do want_ in your repo, like source code / tests you've written, but they may be of incorrect or discouraged format.
### Usage
There are two main ways to use Alliser: run it yourself in JS/TS code, or run it via command line.
##### Command line usage
Command line version exits with status 0 if no conflicting files are found. If files are found, exit status is 1 and files are listed to console.
Run in one folder (src), looking for files that dont match one type (.ts)
```bash
alliser .ts src
```Or in multiple folders & multiple extensions
```bash
alliser .ts,.tsx src,tests,bin
```Possible output for incorrect files:
```bash
Alliser found errors: following files are not allowed formats (.ts)
tests/fixtures/index.cs
tests/fixtures/index.js
tests/fixtures/index.py
tests/fixtures/index.rs
tests/fixtures/subfolder1/submodule2.js
tests/fixtures/subfolder2/submodule.js
```##### Programmatic use
You can also use Alliser to just fetch list of problematic files, and do your own thing with them.
```javascript
import alliser from 'alliser';// Accepts an array of extensions, and an array of folders.
const incorrectFiles = alliser.check(['.ts', '.tsx'], ['src', 'tests'])console.log(incorrectFiles);
// [
// tests/fixtures/index.cs
// tests/fixtures/index.js
// tests/fixtures/index.py
// tests/fixtures/index.rs
// tests/fixtures/subfolder1/submodule2.js
// tests/fixtures/subfolder2/submodule.js
// ]```
#### Default ignores
Alliser is smart enough not to list files from folders like `node_modules` or `.git`. If you feel like some common ignore is missing from defaults, PRs & issues are welcome.
### What's in the name?
"Alliser" is picked from GRR Martins "A Song Of Ice And Fire". Alliser Thorne is a character who would definitely tell you if you're of "the wrong type".