Skip to content

Commit cfff176

Browse files
committed
feat: Add module eslint-config-zillow-typescript
1 parent c05f01c commit cfff176

16 files changed

+853
-1
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint:rules:jest": "eslint-find-rules --unused packages/eslint-config-zillow-base/jest.js --no-core",
1414
"lint:rules:main": "eslint-find-rules --unused packages/eslint-config-zillow/index.js",
1515
"lint:rules:mocha": "eslint-find-rules --unused packages/eslint-config-zillow-base/mocha.js --no-core",
16-
"lint:rules:typescript": "eslint-find-rules --unused packages/eslint-config-zillow-base/typescript.js --no-core",
16+
"lint:rules:typescript": "eslint-find-rules --unused packages/eslint-config-zillow-typescript/index.js --no-core",
1717
"lint:prettier": "eslint --print-config packages/eslint-config-zillow/index.js | eslint-config-prettier-check",
1818
"pretest": "lerna run prepare --loglevel error && npm run --silent lint",
1919
"test": "jest",
@@ -121,6 +121,7 @@
121121
"babel-preset-zillow": "file:packages/babel-preset-zillow",
122122
"eslint-config-zillow": "file:packages/eslint-config-zillow",
123123
"eslint-config-zillow-base": "file:packages/eslint-config-zillow-base",
124+
"eslint-config-zillow-typescript": "file:packages/eslint-config-zillow-typescript",
124125
"eslint-plugin-zillow": "file:packages/eslint-plugin-zillow",
125126
"prettier-config-zillow": "file:packages/prettier-config-zillow",
126127
"zillow-browser-shims": "file:packages/zillow-browser-shims",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# override root to minimize conflicts with upstream
2+
3+
[*.js]
4+
indent_size = 2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
rules:
3+
prettier/prettier: [error, { tabWidth: 2 }]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Zillow
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# eslint-config-zillow-typescript
2+
3+
> Zillow's ESLint config for TypeScript, following our code conventions
4+
5+
[![npm version](https://img.shields.io/npm/v/eslint-config-zillow-typescript.svg)](https://www.npmjs.com/package/eslint-config-zillow-typescript)
6+
[![Build Status](https://travis-ci.org/zillow/javascript.svg?branch=latest)](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).
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
extends: [
3+
'./rules/prettier',
4+
'./rules/eslint-recommended',
5+
'./rules/recommended',
6+
'./rules/recommended-requiring-type-checking',
7+
'./rules/all-remaining',
8+
'./rules/other-plugin-overrides',
9+
].map(require.resolve),
10+
11+
parser: require.resolve('@typescript-eslint/parser'),
12+
13+
parserOptions: {
14+
ecmaVersion: 2018,
15+
sourceType: 'module',
16+
project: ['./tsconfig.json'],
17+
},
18+
19+
plugins: ['@typescript-eslint'],
20+
21+
rules: {},
22+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "eslint-config-zillow-typescript",
3+
"version": "0.0.0-alpha.0",
4+
"description": "Zillow's ESLint config for TypeScript, following our code conventions",
5+
"main": "index.js",
6+
"files": [
7+
"index.js",
8+
"prettier.config.js",
9+
"rules"
10+
],
11+
"scripts": {
12+
"test": "echo \"Run tests from root\" && exit 1"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/zillow/javascript"
17+
},
18+
"keywords": [
19+
"eslint",
20+
"eslintconfig",
21+
"config",
22+
"zillow",
23+
"typescript",
24+
"code conventions"
25+
],
26+
"author": "Daniel Stockman <[email protected]> (https://twitter.com/@evocateur)",
27+
"license": "MIT",
28+
"homepage": "https://github.com/zillow/javascript/tree/latest/packages/eslint-config-zillow-typescript#readme",
29+
"engines": {
30+
"node": ">= 10.17"
31+
},
32+
"peerDependencies": {
33+
"@typescript-eslint/eslint-plugin": "^4.2.0",
34+
"@typescript-eslint/parser": "^4.2.0",
35+
"eslint": ">=7.0.0",
36+
"eslint-plugin-prettier": "^3.1.4",
37+
"prettier": "^2.1.2",
38+
"typescript": "^4.0.3"
39+
},
40+
"dependencies": {
41+
"prettier-config-zillow": "file:../prettier-config-zillow"
42+
}
43+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('prettier-config-zillow');

0 commit comments

Comments
 (0)