|
3 | 3 | // ensure up-to-date JSON |
4 | 4 | require('../lib/render-configs'); |
5 | 5 |
|
| 6 | +const fs = require('fs'); |
| 7 | +const path = require('path'); |
| 8 | + |
6 | 9 | const { configs, processors, rules } = require('..'); |
7 | 10 |
|
8 | 11 | describe('eslint-plugin-zillow', () => { |
@@ -49,13 +52,25 @@ describe('eslint-plugin-zillow', () => { |
49 | 52 | ], |
50 | 53 | }, |
51 | 54 | recommended: { |
52 | | - parser: expect.stringContaining('babel-eslint'), |
| 55 | + parser: require.resolve('babel-eslint'), |
53 | 56 | rules: { |
54 | 57 | 'zillow/react/jsx-indent': ['off', 4], |
55 | 58 | 'max-len': ['warn', 100, 4, { ignoreComments: false }], |
56 | 59 | 'zillow/import/prefer-default-export': ['off'], |
57 | 60 | }, |
58 | 61 | }, |
| 62 | + typescript: { |
| 63 | + overrides: [ |
| 64 | + { |
| 65 | + files: ['**/*.ts?(x)'], |
| 66 | + parser: require.resolve('@typescript-eslint/parser'), |
| 67 | + plugins: ['zillow'], |
| 68 | + rules: { |
| 69 | + 'zillow/@typescript-eslint/await-thenable': ['error'], |
| 70 | + }, |
| 71 | + }, |
| 72 | + ], |
| 73 | + }, |
59 | 74 | }); |
60 | 75 |
|
61 | 76 | const importResolverConfig = configs.recommended.settings['import/resolver']; |
@@ -103,3 +118,28 @@ describe('eslint-plugin-zillow', () => { |
103 | 118 | }); |
104 | 119 | }); |
105 | 120 | }); |
| 121 | + |
| 122 | +describe('rendered config', () => { |
| 123 | + // can't use require() because entry mutates those modules :P |
| 124 | + const readJSON = filePath => |
| 125 | + JSON.parse(fs.readFileSync(path.resolve(__dirname, filePath), 'utf8')); |
| 126 | + |
| 127 | + describe('recommended.json', () => { |
| 128 | + const renderedConfigRecommended = readJSON('../lib/configs/recommended.json'); |
| 129 | + |
| 130 | + it('has unresolved parser', () => { |
| 131 | + expect(renderedConfigRecommended).toHaveProperty('parser', 'babel-eslint'); |
| 132 | + }); |
| 133 | + }); |
| 134 | + |
| 135 | + describe('typescript.json', () => { |
| 136 | + const renderedConfigTypescript = readJSON('../lib/configs/typescript.json'); |
| 137 | + |
| 138 | + it('has unresolved parser', () => { |
| 139 | + expect(renderedConfigTypescript.overrides[0]).toHaveProperty( |
| 140 | + 'parser', |
| 141 | + '@typescript-eslint/parser' |
| 142 | + ); |
| 143 | + }); |
| 144 | + }); |
| 145 | +}); |
0 commit comments