source: frontend/node_modules/eslint-plugin-jsx-a11y/__tests__/src/util/parserOptionsMapper-test.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.8 KB
Line 
1import { version as eslintVersion } from 'eslint/package.json';
2import test from 'tape';
3import semver from 'semver';
4
5import parserOptionsMapper from '../../__util__/parserOptionsMapper';
6
7const usingLegacy = semver.major(eslintVersion) < 9;
8
9test('parserOptionsMapper', (t) => {
10 const expectedResult = usingLegacy
11 ? {
12 code: '<div />',
13 errors: [],
14 options: {},
15 parserOptions: {
16 ecmaVersion: 2018,
17 ecmaFeatures: {
18 experimentalObjectRestSpread: true,
19 jsx: true,
20 },
21 },
22 settings: {},
23 }
24 : {
25 code: '<div />',
26 errors: [],
27 options: {},
28 languageOptions: {
29 ecmaVersion: 'latest',
30 parserOptions: {
31 ecmaFeatures: {
32 experimentalObjectRestSpread: true,
33 jsx: true,
34 },
35 },
36 },
37 settings: {},
38 };
39
40 t.deepEqual(
41 parserOptionsMapper({
42 code: '<div />',
43 errors: [],
44 options: {},
45 }),
46 expectedResult,
47 'returns a test case object',
48 );
49
50 const expectedResult2 = usingLegacy
51 ? {
52 code: '<div />',
53 errors: [],
54 options: {},
55 parserOptions: {
56 ecmaVersion: 5,
57 ecmaFeatures: {
58 experimentalObjectRestSpread: true,
59 jsx: true,
60 },
61 },
62 settings: {},
63 }
64 : {
65 code: '<div />',
66 errors: [],
67 options: {},
68 languageOptions: {
69 ecmaVersion: 5,
70 parserOptions: {
71 ecmaFeatures: {
72 experimentalObjectRestSpread: true,
73 jsx: true,
74 },
75 },
76 },
77 settings: {},
78 };
79 t.deepEqual(
80 parserOptionsMapper({
81 code: '<div />',
82 errors: [],
83 options: {},
84 languageOptions: {
85 ecmaVersion: 5,
86 },
87 }),
88 expectedResult2,
89 'allows for overriding parserOptions',
90 );
91
92 t.end();
93});
Note: See TracBrowser for help on using the repository browser.