The eslint config we use at crewmeister.
In order to asure we all use the same coding style across crewmeister, this repo defines the rules executed by eslint.
In any repo (that should be an npm package) install it like this
npm install eslint-config-crewmeister --save-dev
In order to use it, you can call eslint-crewmeister
from within the project.
The above install adds the executable to your node_modules/bin
folder.
You should add it to the package.json
inside the scripts directory, e.g. like this
"scripts": {
// ...
"lint": "eslint-crewmeister src"
// ...
}
Best practice is also to use the lint before the test run, so that no lint errors slips through. E.g. like this
"scripts": {
// ...
"test": "npm run lint && ..."
// ...
}
In development mode, where you also want to work on this repo here do the following:
> cd crewmeister/repos/eslint-config-crewmeister
npm link # creates a local sym link that refers to this repo here
> cd crewmeister/repos/<what-you-are-working-on>
> npm link eslint-config-crewmeister # use the sym link created above
- update the [CHANGELOG.md]
- use
npm version major
to go up to the next version, always going up to next major for now
By default our coding style is derived from the airbnb style. All modifications/addons are added here.
- 1.1 Globals: For the tests we provide
it
anddescribe
as globals
-
2.1 ??? do this that
// short one line arrow functions // DON'T const func = () => x + y; // DO const func = () => x + y; // long one line arrow functions, function body shall be on the next line, including ";" // DO const func = () => oneLongVariable + anotherLongVariable - orSomethingThatMakesThisQuiteLong; // nested calls // DO const func = () => house(thatHas(threeNeighbors())); // if line doesnt get tooo long const func = () => house( thatHas( threeNeighbors())); // can also be written like this, for clarity // `promiseThat` and alikes are an exception it('test description', () => promiseThat( something(), fulfills())); it('test description', () => promiseThat( something( needsAParameter( whichNeedsAnotherOne()))); // logical blocks are separated by new-lines, functions/tests can be separated as above, const SECOND = 1000; const MINUTE = 60 * SECOND; const HOUR = 60 * MINUTE; const DAY = 24 * HOUR; const house = new HouseMusic(); // constants/variables that belong together as a logical block may be written without new-lines in between import { promiseThat } from 'hamjest'; import { promiseThat, assertThat, } from 'hamjest';
In doubt, in general inside one file, the coding style shall be kept! Which means, what is a logical block, where new-lines are added, this is determined by the existing file, which means, don't come in and change the complete file first.