1 | "use strict";
|
2 |
|
3 | var _checkSetup = require("@sharyn/check-setup");
|
4 |
|
5 |
|
6 | var config = {
|
7 | extends: [],
|
8 | plugins: [],
|
9 | env: {
|
10 | browser: true
|
11 | },
|
12 | globals: {},
|
13 | rules: {
|
14 | 'no-unused-expressions': 0,
|
15 | 'no-underscore-dangle': 0,
|
16 | 'func-names': 0,
|
17 | 'no-unexpected-multiline': 2,
|
18 | semi: [2, 'never']
|
19 | },
|
20 | settings: {}
|
21 | };
|
22 |
|
23 | if ((0, _checkSetup.hasPackage)('eslint-config-airbnb') && (0, _checkSetup.hasPackage)('eslint-config-airbnb-base')) {
|
24 | throw Error('Your package.json should either have eslint-config-airbnb or eslint-config-airbnb-base as a dependency but not both');
|
25 | }
|
26 |
|
27 | if ((0, _checkSetup.hasPackage)('eslint-config-airbnb')) {
|
28 | config.extends.push('airbnb');
|
29 |
|
30 | if (!(0, _checkSetup.hasPackage)('eslint-plugin-import')) {
|
31 | throw Error('eslint-config-airbnb requires having eslint-plugin-import installed');
|
32 | }
|
33 |
|
34 | if (!(0, _checkSetup.hasPackage)('eslint-plugin-react')) {
|
35 | throw Error('eslint-config-airbnb requires having eslint-plugin-react installed');
|
36 | }
|
37 |
|
38 | if (!(0, _checkSetup.hasPackage)('eslint-plugin-jsx-a11y')) {
|
39 | throw Error('eslint-config-airbnb requires having eslint-plugin-jsx-a11y installed');
|
40 | }
|
41 | }
|
42 |
|
43 | if ((0, _checkSetup.hasPackage)('eslint-config-airbnb-base')) {
|
44 | config.extends.push('airbnb-base');
|
45 |
|
46 | if (!(0, _checkSetup.hasPackage)('eslint-plugin-import')) {
|
47 | throw Error('eslint-config-airbnb-base requires having eslint-plugin-import installed');
|
48 | }
|
49 | }
|
50 |
|
51 | if ((0, _checkSetup.hasPackage)('jest-puppeteer')) {
|
52 | config.globals.page = true;
|
53 | config.globals.browser = true;
|
54 | config.globals.jestPuppeteer = true;
|
55 | }
|
56 |
|
57 | if ((0, _checkSetup.hasPackage)('jest')) {
|
58 | config.env.jest = true;
|
59 | }
|
60 |
|
61 | if ((0, _checkSetup.hasPackage)('eslint-plugin-flowtype')) {
|
62 | config.extends.push('plugin:flowtype/recommended');
|
63 | config.plugins.push('flowtype');
|
64 |
|
65 | if (!(0, _checkSetup.hasPackage)('flow-bin')) {
|
66 | throw Error('eslint-plugin-flowtype requires having flow-bin installed');
|
67 | }
|
68 |
|
69 | if (!(0, _checkSetup.hasPackage)('babel-eslint')) {
|
70 | throw Error('eslint-plugin-flowtype requires having babel-eslint installed');
|
71 | }
|
72 | }
|
73 |
|
74 | if ((0, _checkSetup.hasPackage)('eslint-plugin-prettier')) {
|
75 | config.plugins.push('prettier');
|
76 | config.rules['prettier/prettier'] = 2;
|
77 |
|
78 | if (!(0, _checkSetup.hasPackage)('prettier')) {
|
79 | throw Error('eslint-plugin-prettier requires having prettier installed');
|
80 | }
|
81 | }
|
82 |
|
83 | if ((0, _checkSetup.hasPackage)('eslint-config-prettier')) {
|
84 | config.extends.push('prettier');
|
85 |
|
86 | if ((0, _checkSetup.hasPackage)('react')) {
|
87 | config.extends.push('prettier/react');
|
88 | }
|
89 |
|
90 | if ((0, _checkSetup.hasPackage)('flow-bin')) {
|
91 | config.extends.push('prettier/flowtype');
|
92 | }
|
93 |
|
94 | if (!(0, _checkSetup.hasPackage)('prettier')) {
|
95 | throw Error('eslint-config-prettier requires having prettier installed');
|
96 | }
|
97 | }
|
98 |
|
99 | if ((0, _checkSetup.hasPackage)('eslint-plugin-react')) {
|
100 | config.rules['react/require-default-props'] = 0;
|
101 | config.rules['react/jsx-filename-extension'] = [2, {
|
102 | extensions: ['.js']
|
103 | }];
|
104 |
|
105 | if (!(0, _checkSetup.hasPackage)('eslint-config-airbnb')) {
|
106 | config.extends.push('plugin:react/recommended');
|
107 | }
|
108 |
|
109 | if (!(0, _checkSetup.hasPackage)('react')) {
|
110 | throw Error('eslint-plugin-react requires having react installed');
|
111 | }
|
112 | }
|
113 |
|
114 | if ((0, _checkSetup.hasPackage)('eslint-plugin-import')) {
|
115 | config.rules['import/prefer-default-export'] = 0;
|
116 | }
|
117 |
|
118 | if ((0, _checkSetup.hasPackage)('eslint-import-resolver-babel-module')) {
|
119 | config.settings['import/resolver'] = {
|
120 | 'babel-module': {}
|
121 | };
|
122 |
|
123 | if (!(0, _checkSetup.hasPackage)('@babel/core')) {
|
124 | throw Error('eslint-import-resolver-babel-module requires having @babel/core installed');
|
125 | }
|
126 |
|
127 | if (!(0, _checkSetup.hasPackage)('babel-plugin-module-resolver')) {
|
128 | throw Error('eslint-import-resolver-babel-module requires having babel-plugin-module-resolver installed');
|
129 | }
|
130 |
|
131 | if (!(0, _checkSetup.hasPackage)('eslint-plugin-import')) {
|
132 | throw Error('eslint-import-resolver-babel-module requires having eslint-plugin-import installed');
|
133 | }
|
134 | }
|
135 |
|
136 | if ((0, _checkSetup.hasPackage)('@babel/plugin-proposal-do-expressions') && !(0, _checkSetup.hasPackage)('babel-eslint')) {
|
137 | throw Error('@babel/plugin-proposal-do-expressions requires having babel-eslint installed');
|
138 | }
|
139 |
|
140 | if ((0, _checkSetup.hasPackage)('@babel/plugin-proposal-nullish-coalescing-operator') && !(0, _checkSetup.hasPackage)('babel-eslint')) {
|
141 | throw Error('@babel/plugin-proposal-nullish-coalescing-operator requires having babel-eslint installed');
|
142 | }
|
143 |
|
144 | if ((0, _checkSetup.hasPackage)('@babel/plugin-proposal-optional-chaining') && !(0, _checkSetup.hasPackage)('babel-eslint')) {
|
145 | throw Error('@babel/plugin-proposal-optional-chaining requires having babel-eslint installed');
|
146 | }
|
147 |
|
148 | if ((0, _checkSetup.hasPackage)('@babel/plugin-proposal-pipeline-operator') && !(0, _checkSetup.hasPackage)('babel-eslint')) {
|
149 | throw Error('@babel/plugin-proposal-pipeline-operator requires having babel-eslint installed');
|
150 | }
|
151 |
|
152 | if ((0, _checkSetup.hasPackage)('flow-bin') && !(0, _checkSetup.hasPackage)('babel-eslint')) {
|
153 | throw Error('flow-bin requires having babel-eslint installed');
|
154 | }
|
155 |
|
156 | if ((0, _checkSetup.hasPackage)('babel-eslint')) {
|
157 | config.parser = 'babel-eslint';
|
158 | }
|
159 |
|
160 | if ((0, _checkSetup.hasPackage)('react')) {
|
161 | config.parserOptions = {
|
162 | ecmaFeatures: {
|
163 | jsx: true
|
164 | }
|
165 | };
|
166 | }
|
167 |
|
168 | module.exports = config; |
\ | No newline at end of file |