UNPKG

2.73 kBMarkdownView Raw
1<div align="center">
2<img width="500" src="https://cdn.rawgit.com/crystal-ball/eslint-config-eloquence/master/assets/logos.png" alt="Extends Airbnb code quality rules with Prettier.js formatting">
3</div>
4
5# Crystal Ball ESLint Configs
6[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
7
8## Installing:
9Add the package and Prettier as a dev dependencies to your project:
10```sh
11npm i eslint-config-healthsparq prettier -D
12```
13_We recommend adding Prettier as a project dependency. (Some editors will only use
14Prettier as a dependency if it is in the `package.json`)_
15
16If you are using the web configs, install the webpack resolver as well:
17```sh
18npm i eslint-import-resolver-webpack -D
19```
20
21#### Flow
22Static typing using flow is supported through the `eslint-plugin-import` package.
23
24## Usage
25Extending this package's config will handle setting the base parserOptions, parser,
26plugins and env. There are seperate configs for Node projects and web projects
27to handle turning on/off features like JSX, webpack resolving, `.mjs` file
28extensions, etc. The configs are `node` and `web` and can be extended like so:
29
30#### Webpack Project
31```javascript
32// .eslintrc.js
33module.exports = { extends: '@crystal-ball/eloquence/web' }
34```
35#### Node Project
36```javascript
37// .eslintrc.js
38module.exports = { extends: '@crystal-ball/eloquence/node' }
39```
40
41#### Overriden Rules
42The only Airbnb code quality rule that is overriden is setting
43[no-use-before-define](https://eslint.org/docs/rules/no-use-before-define) to
44`{ functions: false }`. This allows propTypes of
45stateless functional components to be decalred before the component defintion using
46a function declarartion:
47
48```javascript
49Radical.propTypes = {
50 name: string.isRequired
51}
52
53export default function Radical({ name }) {
54 return <h1>{name} is RADICAL!</h1>
55}
56```
57
58This lets us always declare our prop types before the component definition, which
59is helpful when evaluating some new component.
60
61#### Dependencies
62All dependencies required for running ESLint will be installed as dependencies of
63this package. This ensures that there are no conflicting versions of ESLint in a
64consuming project's dependencies. Installed dependencies include:
65- eslint
66- babel-eslint
67- eslint-config-airbnb
68- eslint-config-prettier
69- eslint-plugin-flowtype
70- eslint-plugin-import
71- eslint-plugin-jsx-a11y
72- eslint-plugin-prettier
73- eslint-plugin-react
74
75## TypeScript
76Linting for TypeScript is an opt-in. First, add the ESLint TS parser:
77
78```shell
79npm i typescript-eslint-parser
80```
81
82Then extend the TyepScript configuration:
83
84```javascript
85// .eslintrc.js
86module.exports = {
87 extends: '@crystal-ball/eloquence/typescript'
88}
89```