|
| 1 | +# eslint-config-zillow-typescript |
| 2 | + |
| 3 | +> Zillow's ESLint config for TypeScript, following our code conventions |
| 4 | +
|
| 5 | +[](https://www.npmjs.com/package/eslint-config-zillow-typescript) |
| 6 | +[](https://travis-ci.org/zillow/javascript) |
| 7 | + |
| 8 | +## Usage |
| 9 | + |
| 10 | +Note: Unlike other Zillow eslint config plugins, this module is designed to be used in tandem with another extended config such as [eslint-config-zillow](https://npmjs.com/eslint-config-zillow). |
| 11 | + |
| 12 | +To install with all necessary `peerDependencies`, use [install-peerdeps](https://github.com/nathanhleung/install-peerdeps#usage): |
| 13 | + |
| 14 | +```sh |
| 15 | +npx install-peerdeps --dev eslint-config-zillow eslint-config-zillow-typescript |
| 16 | +``` |
| 17 | + |
| 18 | +All exported configs should be added to your [ESlint configuration file](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) `extends`. |
| 19 | +For example, in a JSON `.eslintrc`: |
| 20 | + |
| 21 | +```json |
| 22 | +{ |
| 23 | + "extends": ["zillow", "zillow-typescript"] |
| 24 | +} |
| 25 | +``` |
| 26 | + |
| 27 | +### Project Config |
| 28 | + |
| 29 | +All flavors of this config expect your `tsconfig.json` to be in the current working directory (relative to your eslint config), which is extremely common. If it is elsewhere (say, a monorepo leaf), you will need to override various [`parserOptions`](https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md): |
| 30 | + |
| 31 | +```js |
| 32 | +// .eslintrc.js |
| 33 | +module.exports = { |
| 34 | + extends: ['zillow', 'zillow-typescript'], |
| 35 | + parserOptions: { |
| 36 | + tsconfigRootDir: __dirname, |
| 37 | + project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'], |
| 38 | + }, |
| 39 | +}; |
| 40 | +``` |
| 41 | + |
| 42 | +### `prettier` Editor Plugin Integration |
| 43 | + |
| 44 | +Unfortunately, super-useful editor plugins like `prettier-atom` and `prettier-vscode` do not load Prettier settings from ESLint config, which is where we load our Prettier options from. To workaround this, add a `.prettierrc.js` or `prettier.config.js` file to your repo root with the following content: |
| 45 | + |
| 46 | +```js |
| 47 | +module.exports = require('prettier-config-zillow'); |
| 48 | +``` |
| 49 | + |
| 50 | +## Related |
| 51 | + |
| 52 | + - [Zillow's overarching ESLint config](https://npmjs.com/eslint-config-zillow) |
| 53 | + - [Zillow's Prettier config](https://npmjs.com/prettier-config-zillow) |
| 54 | + - [Zillow's Javascript code conventions](https://github.com/zillow/javascript) |
| 55 | + |
| 56 | +## Development |
| 57 | + |
| 58 | +Consider adding test cases if you're making complicated rules changes, like anything involving regexes. Perhaps in a distant future, we could use literate programming to structure our README as test cases for our .eslintrc? |
| 59 | + |
| 60 | +You can run tests (from the repo root) with `npm test`. |
| 61 | + |
| 62 | +You can make sure this module lints with itself using `npm run lint` (from the repo root). |
0 commit comments