Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duolingo/splinter
Simple pattern-based linter :rat:
https://github.com/duolingo/splinter
bash grep linter regex unix
Last synced: about 1 month ago
JSON representation
Simple pattern-based linter :rat:
- Host: GitHub
- URL: https://github.com/duolingo/splinter
- Owner: duolingo
- License: apache-2.0
- Created: 2018-01-05T05:09:10.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-17T05:52:00.000Z (6 months ago)
- Last Synced: 2024-06-17T06:52:45.841Z (6 months ago)
- Topics: bash, grep, linter, regex, unix
- Language: Shell
- Homepage:
- Size: 17.6 KB
- Stars: 41
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Splinter
Here's a dead simple,
pattern-based linter for code
in any language.It's not that smart, but
it needs only Bash and runs
on any Unix.Define your rules in
a text file as a list of
message/regex pairs.## Usage
1. Copy-paste `splinter` into your project and make it executable:
```bash
chmod +x splinter
```1. Create a rule file named something like `rules.txt`:
```text
# This is a comment and will be ignored.
# Each rule is defined as an error message followed
# by the regex (POSIX ERE) that should trigger it.Remove trailing whitespace
\s$Use `assert.strictEqual()` instead of `assert.equal()`
assert\.equal
```1. Run Splinter:
```bash
# The rule file is the only required argument. Optionally, provide
# a list of files/directories to lint (default: current directory)
./splinter rules.txt index.js src
```1. See the output! The exit code will be 1 if violations are found - useful for CI.
```text
index.js:25:Remove trailing whitespace
index.js:26:Remove trailing whitespace
src/foobar.test.js:130:Use `assert.strictEqual()` instead of `assert.equal()`
```Splinter will ignore violations on any line of code that contains `splinter:ignore` in a comment.
### Running with pre-commit
You can also set up this repo as a [pre-commit hook](https://pre-commit.com/). For example:
```yaml
- repo: https://github.com/duolingo/splinter.git
rev: 1.4.0
hooks:
- id: splinter
args:
- config/splinter-rules-py.txt
files: \.py$
```_Duolingo is hiring! Apply at https://www.duolingo.com/careers_