UNPKG

3.23 kBMarkdownView Raw
1@balena/lint
2==========
3
4`@balena/lint` is a linter based on [coffeelint](https://github.com/clutchski/coffeelint),
5[coffeescope2](https://github.com/za-creature/coffeescope), [tslint](https://palantir.github.io/tslint/) and [prettier](https://github.com/prettier/prettier) to detect style errors based on balena.io coding guidelines.
6
7Overview
8--------
9
10`@balena/lint` uses balena's `coffeelint.json`, `tslint.json` and `.prettierrc`.
11If a `coffeelint.json` or `tslint.json` is found in the to-be-linted project
12directory or its parents then the rules found in it will be merged with the default `@balena/lint` ones.
13Another way to to override the default balena lint rules is by specifying a configuration
14file with the `-f` parameter.
15
16## Typescript
17
18By default, only `.coffee` files will be linted. `.ts` and `.tsx` files can be
19linted by using the `--typescript` parameter.
20
21## Prettier
22
23You can reference the prettier configuration file to your consumer project
24from `./config/.prettierrc`.
25You can disable the prettier format checks by using the `--no-prettier` parameter.
26
27Usage
28-----
29
30You can use this module as:
31
321. A standalone project by installing it with `npm install -g @balena/lint`:
33
34 ```
35 kostas@macbook:~/balena/test$ balena-lint src/
36 ✓ src/test.coffee
37
38 ✓ Ok! » 0 errors and 0 warnings in 1 file
39 ```
40
412. A development dependency in `package.json` with ```npm install --save-dev @balena/lint```. Then
42 you can use the module in your build/testing process:
43
44 ```
45 package.json
46 ------------
47 ...
48 "scripts": {
49 "lint": "balena-lint src/ && echo \"Done!\""
50 },
51 ...
52
53 kostas@macbook:~/balena/test$ npm run lint
54
55 > test@1.0.0 lint /Users/kostas/balena/test
56 > balena-lint src/ && echo "Done!"
57
58 ✓ src/test.coffee
59
60 ✓ Ok! » 0 errors and 0 warnings in 1 file
61
62 Done!
63
64 ```
65
663. A development dependency, that will get picked up by your IDE/Editor coffeelint/tslint/prettier.
67
68Manually create these config files in your project root:
69
70`tslint.json`
71
72```json
73// if using prettier in your project
74{
75 "extends": [
76 "balena-lint/config/tslint-prettier.json"
77 ]
78}
79
80// plain TypeScript
81{
82 "extends": [
83 "balena-lint/config/tslint.json"
84 ]
85}
86```
87
88For coffeelint create `coffeelint.json`
89
90```json
91{
92 "extends": [
93 "balena-lint/config/coffeelint.json"
94 ]
95}
96```
97
98For prettier config create `.prettierrc.js`
99
100```js
101const fs = require('fs');
102
103module.exports = JSON.parse(fs.readFileSync('./node_modules/balena-lint/config/.prettierrc', 'utf8'));
104```
105
106Support
107-------
108
109If you're having any problem, please [raise an issue](https://github.com/balena-io-modules/node-balena-lint/issues/new) on GitHub and the balena.io team will be happy to help.
110
111Tests
112-----
113
114Run the test suite by doing:
115
116```sh
117$ npm install && npm test
118```
119
120Contribute
121----------
122
123- Issue Tracker: [github.com/balena-io-modules/node-balena-lint/issues](https://github.com/balena-io-modules/node-balena-lint/issues)
124- Source Code: [github.com/balena-io-modules/node-balena-lint](https://github.com/balena-io-modules/node-balena-lint)
125
126Before submitting a PR, please make sure that you include tests, and that `npm run lint` runs without a warning.
127
128License
129-------
130
131The project is licensed under the Apache 2.0 license.