Skip to content

Commit 99e3882

Browse files
committed
test(config/eslint): add snapshot coverage for ESLint configurations
1 parent 1afb9db commit 99e3882

File tree

2 files changed

+326
-0
lines changed

2 files changed

+326
-0
lines changed
Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`ESLint React configuration 1`] = `
4+
Object {
5+
"extends": Array [
6+
<PROJECT_ROOT>/node_modules/eslint-config-airbnb/index.js,
7+
<PROJECT_ROOT>/node_modules/eslint-config-airbnb-typescript/index.js,
8+
"plugin:jest/recommended",
9+
<PROJECT_ROOT>/node_modules/eslint-config-prettier/index.js,
10+
"plugin:react-hooks/recommended",
11+
],
12+
"overrides": Array [
13+
Object {
14+
"extends": Array [
15+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
16+
],
17+
"files": Array [
18+
"**/*.ts?(x)",
19+
],
20+
"rules": Object {
21+
"@typescript-eslint/dot-notation": "error",
22+
"@typescript-eslint/no-implied-eval": "error",
23+
"@typescript-eslint/no-throw-literal": "error",
24+
"@typescript-eslint/return-await": "error",
25+
"no-implied-eval": "off",
26+
"no-throw-literal": "off",
27+
"react/prop-types": "off",
28+
},
29+
},
30+
Object {
31+
"files": Array [
32+
"**/__tests__/**/*.+(js|jsx|ts|tsx)",
33+
"test/**/*.+(js|jsx|ts|tsx)",
34+
"test/**/*.+(test.js|test.jsx|test.ts|test.tsx)",
35+
"e2e/**/*.+(test.js|test.jsx|test.ts|test.tsx)",
36+
"**/*.+(test.js|test.jsx|test.ts|test.tsx)",
37+
],
38+
"rules": Object {
39+
"@typescript-eslint/no-unsafe-assignment": "off",
40+
"@typescript-eslint/no-unsafe-return": "off",
41+
"no-empty": Array [
42+
"error",
43+
Object {
44+
"allowEmptyCatch": true,
45+
},
46+
],
47+
},
48+
},
49+
Object {
50+
"files": Array [
51+
"**/*/__tests__/helpers/**/*",
52+
"**/*/__tests__/utils/**/*",
53+
],
54+
"rules": Object {
55+
"jest/no-export": "off",
56+
},
57+
},
58+
],
59+
"plugins": Array [
60+
"prettier",
61+
"jest",
62+
"react-hooks",
63+
],
64+
"rules": Object {
65+
"@typescript-eslint/dot-notation": "off",
66+
"@typescript-eslint/no-implied-eval": "off",
67+
"@typescript-eslint/no-throw-literal": "off",
68+
"@typescript-eslint/return-await": "off",
69+
"import/no-extraneous-dependencies": Array [
70+
"error",
71+
Object {
72+
"devDependencies": Array [
73+
"test/**",
74+
"tests/**",
75+
"spec/**",
76+
"**/__tests__/**",
77+
"**/__mocks__/**",
78+
"test.{js,jsx}",
79+
"test.{ts,tsx}",
80+
"test-*.{js,jsx}",
81+
"test-*.{ts,tsx}",
82+
"**/*{.,_}{test,spec}.{js,jsx}",
83+
"**/*{.,_}{test,spec}.{ts,tsx}",
84+
"**/jest.config.js",
85+
"**/jest.config.ts",
86+
"**/jest.setup.js",
87+
"**/jest.setup.ts",
88+
"**/vue.config.js",
89+
"**/vue.config.ts",
90+
"**/webpack.config.js",
91+
"**/webpack.config.ts",
92+
"**/webpack.config.*.js",
93+
"**/webpack.config.*.ts",
94+
"**/rollup.config.js",
95+
"**/rollup.config.ts",
96+
"**/rollup.config.*.js",
97+
"**/rollup.config.*.ts",
98+
"**/gulpfile.js",
99+
"**/gulpfile.ts",
100+
"**/gulpfile.*.js",
101+
"**/gulpfile.*.ts",
102+
"**/Gruntfile{,.js}",
103+
"**/Gruntfile{,.ts}",
104+
"**/protractor.conf.js",
105+
"**/protractor.conf.ts",
106+
"**/protractor.conf.*.js",
107+
"**/protractor.conf.*.ts",
108+
"**/karma.conf.js",
109+
"**/karma.conf.ts",
110+
"**/.eslintrc.js",
111+
"**/.eslintrc.ts",
112+
"jest/**",
113+
"test/**",
114+
"e2e/**",
115+
"**/*.config.{js,cjs,ts}",
116+
],
117+
"optionalDependencies": false,
118+
},
119+
],
120+
"import/prefer-default-export": "off",
121+
"no-implied-eval": "error",
122+
"no-throw-literal": "error",
123+
"no-void": Array [
124+
"error",
125+
Object {
126+
"allowAsStatement": true,
127+
},
128+
],
129+
"prettier/prettier": "error",
130+
"react/prop-types": "error",
131+
},
132+
}
133+
`;
134+
135+
exports[`ESLint configuration 1`] = `
136+
Object {
137+
"extends": Array [
138+
<PROJECT_ROOT>/node_modules/eslint-config-airbnb-base/index.js,
139+
<PROJECT_ROOT>/node_modules/eslint-config-airbnb-typescript/base.js,
140+
"plugin:jest/recommended",
141+
<PROJECT_ROOT>/node_modules/eslint-config-prettier/index.js,
142+
],
143+
"overrides": Array [
144+
Object {
145+
"extends": Array [
146+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
147+
],
148+
"files": Array [
149+
"**/*.ts?(x)",
150+
],
151+
"rules": Object {
152+
"@typescript-eslint/dot-notation": "error",
153+
"@typescript-eslint/no-implied-eval": "error",
154+
"@typescript-eslint/no-throw-literal": "error",
155+
"@typescript-eslint/return-await": "error",
156+
"no-implied-eval": "off",
157+
"no-throw-literal": "off",
158+
},
159+
},
160+
Object {
161+
"files": Array [
162+
"**/__tests__/**/*.+(js|jsx|ts|tsx)",
163+
"test/**/*.+(js|jsx|ts|tsx)",
164+
"test/**/*.+(test.js|test.jsx|test.ts|test.tsx)",
165+
"e2e/**/*.+(test.js|test.jsx|test.ts|test.tsx)",
166+
"**/*.+(test.js|test.jsx|test.ts|test.tsx)",
167+
],
168+
"rules": Object {
169+
"@typescript-eslint/no-unsafe-assignment": "off",
170+
"@typescript-eslint/no-unsafe-return": "off",
171+
"no-empty": Array [
172+
"error",
173+
Object {
174+
"allowEmptyCatch": true,
175+
},
176+
],
177+
},
178+
},
179+
Object {
180+
"files": Array [
181+
"**/*/__tests__/helpers/**/*",
182+
"**/*/__tests__/utils/**/*",
183+
],
184+
"rules": Object {
185+
"jest/no-export": "off",
186+
},
187+
},
188+
],
189+
"plugins": Array [
190+
"prettier",
191+
"jest",
192+
],
193+
"rules": Object {
194+
"@typescript-eslint/dot-notation": "off",
195+
"@typescript-eslint/no-implied-eval": "off",
196+
"@typescript-eslint/no-throw-literal": "off",
197+
"@typescript-eslint/return-await": "off",
198+
"import/no-extraneous-dependencies": Array [
199+
"error",
200+
Object {
201+
"devDependencies": Array [
202+
"test/**",
203+
"tests/**",
204+
"spec/**",
205+
"**/__tests__/**",
206+
"**/__mocks__/**",
207+
"test.{js,jsx}",
208+
"test.{ts,tsx}",
209+
"test-*.{js,jsx}",
210+
"test-*.{ts,tsx}",
211+
"**/*{.,_}{test,spec}.{js,jsx}",
212+
"**/*{.,_}{test,spec}.{ts,tsx}",
213+
"**/jest.config.js",
214+
"**/jest.config.ts",
215+
"**/jest.setup.js",
216+
"**/jest.setup.ts",
217+
"**/vue.config.js",
218+
"**/vue.config.ts",
219+
"**/webpack.config.js",
220+
"**/webpack.config.ts",
221+
"**/webpack.config.*.js",
222+
"**/webpack.config.*.ts",
223+
"**/rollup.config.js",
224+
"**/rollup.config.ts",
225+
"**/rollup.config.*.js",
226+
"**/rollup.config.*.ts",
227+
"**/gulpfile.js",
228+
"**/gulpfile.ts",
229+
"**/gulpfile.*.js",
230+
"**/gulpfile.*.ts",
231+
"**/Gruntfile{,.js}",
232+
"**/Gruntfile{,.ts}",
233+
"**/protractor.conf.js",
234+
"**/protractor.conf.ts",
235+
"**/protractor.conf.*.js",
236+
"**/protractor.conf.*.ts",
237+
"**/karma.conf.js",
238+
"**/karma.conf.ts",
239+
"**/.eslintrc.js",
240+
"**/.eslintrc.ts",
241+
"jest/**",
242+
"test/**",
243+
"e2e/**",
244+
"**/*.config.{js,cjs,ts}",
245+
],
246+
"optionalDependencies": false,
247+
},
248+
],
249+
"import/prefer-default-export": "off",
250+
"no-implied-eval": "error",
251+
"no-throw-literal": "error",
252+
"no-void": Array [
253+
"error",
254+
Object {
255+
"allowAsStatement": true,
256+
},
257+
],
258+
"prettier/prettier": "error",
259+
},
260+
}
261+
`;
262+
263+
exports[`Strict ESLint configuration 1`] = `
264+
Object {
265+
"rules": Object {
266+
"import/order": Array [
267+
"error",
268+
Object {
269+
"alphabetize": Object {
270+
"order": "asc",
271+
},
272+
"newlines-between": "always",
273+
"pathGroups": Array [
274+
Object {
275+
"group": "parent",
276+
"pattern": "src/**/*",
277+
"position": "before",
278+
},
279+
Object {
280+
"group": "parent",
281+
"pattern": "test/**/*",
282+
"position": "before",
283+
},
284+
Object {
285+
"group": "parent",
286+
"pattern": "assets/**/*",
287+
"position": "before",
288+
},
289+
],
290+
"pathGroupsExcludedImportTypes": Array [
291+
"builtin",
292+
],
293+
},
294+
],
295+
"sort-imports": Array [
296+
"error",
297+
Object {
298+
"ignoreDeclarationSort": true,
299+
},
300+
],
301+
},
302+
}
303+
`;

src/config/__tests__/eslintrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import eslint from '../eslintrc'
2+
import eslintStrict from '../eslintrc-strict'
3+
import eslintReact from '../eslintrc-react'
4+
5+
import {
6+
winPathSerializer,
7+
relativePathSerializer,
8+
} from '../../test/helpers/serializers'
9+
10+
expect.addSnapshotSerializer(winPathSerializer)
11+
expect.addSnapshotSerializer(relativePathSerializer)
12+
13+
test('ESLint configuration', () => {
14+
expect(eslint).toMatchSnapshot()
15+
})
16+
17+
test('Strict ESLint configuration', () => {
18+
expect(eslintStrict).toMatchSnapshot()
19+
})
20+
21+
test('ESLint React configuration', () => {
22+
expect(eslintReact).toMatchSnapshot()
23+
})

0 commit comments

Comments
 (0)