@teambit/eslint 0.0.881 → 0.0.882
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint.aspect.js +0 -5
- package/dist/eslint.aspect.js.map +1 -1
- package/dist/eslint.composition.js +0 -6
- package/dist/eslint.composition.js.map +1 -1
- package/dist/eslint.linter.js +7 -61
- package/dist/eslint.linter.js.map +1 -1
- package/dist/eslint.main.runtime.js +2 -31
- package/dist/eslint.main.runtime.js.map +1 -1
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/package-tar/teambit-eslint-0.0.882.tgz +0 -0
- package/package.json +3 -3
- package/{preview-1666409808293.js → preview-1666496165706.js} +2 -2
- package/package-tar/teambit-eslint-0.0.881.tgz +0 -0
package/dist/eslint.aspect.js
CHANGED
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ESLintAspect = void 0;
|
|
7
|
-
|
|
8
7
|
function _harmony() {
|
|
9
8
|
const data = require("@teambit/harmony");
|
|
10
|
-
|
|
11
9
|
_harmony = function () {
|
|
12
10
|
return data;
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
return data;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
const ESLintAspect = _harmony().Aspect.create({
|
|
19
15
|
id: 'teambit.defender/eslint'
|
|
20
16
|
});
|
|
21
|
-
|
|
22
17
|
exports.ESLintAspect = ESLintAspect;
|
|
23
18
|
|
|
24
19
|
//# sourceMappingURL=eslint.aspect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ESLintAspect","Aspect","create","id"],"sources":["eslint.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const ESLintAspect = Aspect.create({\n id: 'teambit.defender/eslint',\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["ESLintAspect","Aspect","create","id"],"sources":["eslint.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const ESLintAspect = Aspect.create({\n id: 'teambit.defender/eslint',\n});\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,YAAY,GAAGC,iBAAM,CAACC,MAAM,CAAC;EACxCC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.Logo = void 0;
|
|
9
|
-
|
|
10
8
|
function _react() {
|
|
11
9
|
const data = _interopRequireDefault(require("react"));
|
|
12
|
-
|
|
13
10
|
_react = function () {
|
|
14
11
|
return data;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
return data;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
21
16
|
style: {
|
|
22
17
|
height: '100%',
|
|
@@ -29,7 +24,6 @@ const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
|
29
24
|
},
|
|
30
25
|
src: "https://static.bit.dev/brands/logo-eslint.svg"
|
|
31
26
|
}));
|
|
32
|
-
|
|
33
27
|
exports.Logo = Logo;
|
|
34
28
|
|
|
35
29
|
//# sourceMappingURL=eslint.composition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["eslint.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-eslint.svg\" />\n </div>\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["eslint.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-eslint.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAG,CAAE;EAAC,GAAG,EAAC;AAA+C,EAAG,CAEpF;AAAC"}
|
package/dist/eslint.linter.js
CHANGED
|
@@ -1,90 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.ESLintLinter = void 0;
|
|
13
|
-
|
|
14
10
|
function _defineProperty2() {
|
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
12
|
_defineProperty2 = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _fsExtra() {
|
|
25
18
|
const data = _interopRequireDefault(require("fs-extra"));
|
|
26
|
-
|
|
27
19
|
_fsExtra = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function _path() {
|
|
35
25
|
const data = _interopRequireDefault(require("path"));
|
|
36
|
-
|
|
37
26
|
_path = function () {
|
|
38
27
|
return data;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
return data;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function _lodash() {
|
|
45
32
|
const data = require("lodash");
|
|
46
|
-
|
|
47
33
|
_lodash = function () {
|
|
48
34
|
return data;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
return data;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
function _eslint() {
|
|
55
39
|
const data = require("eslint");
|
|
56
|
-
|
|
57
40
|
_eslint = function () {
|
|
58
41
|
return data;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
return data;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
45
|
function _pMapSeries() {
|
|
65
46
|
const data = _interopRequireDefault(require("p-map-series"));
|
|
66
|
-
|
|
67
47
|
_pMapSeries = function () {
|
|
68
48
|
return data;
|
|
69
49
|
};
|
|
70
|
-
|
|
71
50
|
return data;
|
|
72
51
|
}
|
|
73
|
-
|
|
74
52
|
function _objectHash() {
|
|
75
53
|
const data = _interopRequireDefault(require("object-hash"));
|
|
76
|
-
|
|
77
54
|
_objectHash = function () {
|
|
78
55
|
return data;
|
|
79
56
|
};
|
|
80
|
-
|
|
81
57
|
return data;
|
|
82
58
|
}
|
|
83
|
-
|
|
84
59
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
85
|
-
|
|
86
60
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
87
|
-
|
|
88
61
|
class ESLintLinter {
|
|
89
62
|
constructor(logger, options,
|
|
90
63
|
/**
|
|
@@ -96,30 +69,23 @@ class ESLintLinter {
|
|
|
96
69
|
this.ESLint = ESLint;
|
|
97
70
|
(0, _defineProperty2().default)(this, "displayName", 'ESlint');
|
|
98
71
|
}
|
|
99
|
-
|
|
100
72
|
displayConfig() {
|
|
101
73
|
return JSON.stringify(this.options, null, 2);
|
|
102
74
|
}
|
|
103
|
-
|
|
104
75
|
async lint(context) {
|
|
105
76
|
const longProcessLogger = this.logger.createLongProcessLogger('linting components', context.components.length);
|
|
106
77
|
const eslint = this.createEslint(this.options.config, this.ESLint);
|
|
107
|
-
|
|
108
78
|
if (this.options.tsConfig && context.rootDir) {
|
|
109
79
|
var _this$options, _this$options$config, _this$options$config$;
|
|
110
|
-
|
|
111
80
|
const tsConfigPath = this.createTempTsConfigFile(context.rootDir, context.envRuntime.id, this.options.tsConfig);
|
|
112
|
-
|
|
113
81
|
if ((_this$options = this.options) !== null && _this$options !== void 0 && (_this$options$config = _this$options.config) !== null && _this$options$config !== void 0 && (_this$options$config$ = _this$options$config.overrideConfig) !== null && _this$options$config$ !== void 0 && _this$options$config$.parserOptions) {
|
|
114
82
|
this.options.config.overrideConfig.parserOptions.project = tsConfigPath;
|
|
115
83
|
}
|
|
116
84
|
}
|
|
117
|
-
|
|
118
85
|
const resultsP = (0, _pMapSeries().default)(context.components, async component => {
|
|
119
86
|
longProcessLogger.logProgress(component.id.toString());
|
|
120
87
|
const filesP = component.filesystem.files.map(async file => {
|
|
121
88
|
var _this$options$extensi;
|
|
122
|
-
|
|
123
89
|
// TODO: now that we moved to lint files, maybe it's not required anymore
|
|
124
90
|
// The eslint api will not ignore extensions by default when using lintText, so we do it manually
|
|
125
91
|
if (!((_this$options$extensi = this.options.extensions) !== null && _this$options$extensi !== void 0 && _this$options$extensi.includes(file.extname))) return undefined;
|
|
@@ -127,11 +93,9 @@ class ESLintLinter {
|
|
|
127
93
|
});
|
|
128
94
|
const files = (0, _lodash().compact)(await Promise.all(filesP));
|
|
129
95
|
const lintResults = await eslint.lintFiles(files);
|
|
130
|
-
|
|
131
96
|
if (eslint && this.options.config.fix && lintResults) {
|
|
132
97
|
await _eslint().ESLint.outputFixes(lintResults);
|
|
133
98
|
}
|
|
134
|
-
|
|
135
99
|
const results = (0, _lodash().compact)((0, _lodash().flatten)(lintResults));
|
|
136
100
|
const formatter = await eslint.loadFormatter(this.options.formatter || 'stylish');
|
|
137
101
|
const output = formatter.format(results);
|
|
@@ -182,34 +146,27 @@ class ESLintLinter {
|
|
|
182
146
|
errors: []
|
|
183
147
|
};
|
|
184
148
|
}
|
|
185
|
-
|
|
186
149
|
createTempTsConfigFile(rootDir, envId, tsConfig) {
|
|
187
150
|
const newTsConfig = _objectSpread({}, tsConfig);
|
|
188
|
-
|
|
189
151
|
if (tsConfig.include) {
|
|
190
152
|
newTsConfig.include = tsConfig.include.map(includedPath => `../../${includedPath}`);
|
|
191
153
|
}
|
|
192
|
-
|
|
193
154
|
if (tsConfig.exclude) {
|
|
194
155
|
newTsConfig.exclude = tsConfig.exclude.map(excludedPath => `../../${excludedPath}`);
|
|
195
156
|
}
|
|
196
|
-
|
|
197
157
|
const cacheDir = getCacheDir(rootDir);
|
|
198
|
-
const hash = (0, _objectHash().default)(newTsConfig);
|
|
158
|
+
const hash = (0, _objectHash().default)(newTsConfig);
|
|
159
|
+
// We save the tsconfig with hash here to avoid creating unnecessary tsconfig files
|
|
199
160
|
// this is very important as eslint will be able to cache the tsconfig file and will not need to create another program
|
|
200
161
|
// this affects performance dramatically
|
|
201
|
-
|
|
202
162
|
const tempTsConfigPath = _path().default.join(cacheDir, `bit.tsconfig.eslint.${hash}.json`);
|
|
203
|
-
|
|
204
163
|
if (!_fsExtra().default.existsSync(tempTsConfigPath)) {
|
|
205
164
|
_fsExtra().default.outputJSONSync(tempTsConfigPath, newTsConfig, {
|
|
206
165
|
spaces: 2
|
|
207
166
|
});
|
|
208
167
|
}
|
|
209
|
-
|
|
210
168
|
return tempTsConfigPath;
|
|
211
169
|
}
|
|
212
|
-
|
|
213
170
|
computeComponentResultsWithTotals(results) {
|
|
214
171
|
let totalErrorCount = 0;
|
|
215
172
|
let totalFatalErrorCount = 0;
|
|
@@ -218,9 +175,8 @@ class ESLintLinter {
|
|
|
218
175
|
let totalWarningCount = 0;
|
|
219
176
|
const componentsResults = results.map(result => {
|
|
220
177
|
var _result$errorCount, _result$fatalErrorCou, _result$fixableErrorC, _result$fixableWarnin, _result$warningCount;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
178
|
+
totalErrorCount += (_result$errorCount = result.errorCount) !== null && _result$errorCount !== void 0 ? _result$errorCount : 0;
|
|
179
|
+
// @ts-ignore - missing from the @types/eslint lib
|
|
224
180
|
totalFatalErrorCount += (_result$fatalErrorCou = result.fatalErrorCount) !== null && _result$fatalErrorCou !== void 0 ? _result$fatalErrorCou : 0;
|
|
225
181
|
totalFixableErrorCount += (_result$fixableErrorC = result.fixableErrorCount) !== null && _result$fixableErrorC !== void 0 ? _result$fixableErrorC : 0;
|
|
226
182
|
totalFixableWarningCount += (_result$fixableWarnin = result.fixableWarningCount) !== null && _result$fixableWarnin !== void 0 ? _result$fixableWarnin : 0;
|
|
@@ -246,7 +202,6 @@ class ESLintLinter {
|
|
|
246
202
|
componentsResults
|
|
247
203
|
};
|
|
248
204
|
}
|
|
249
|
-
|
|
250
205
|
computeManyComponentsTotals(componentsResults) {
|
|
251
206
|
let totalErrorCount = 0;
|
|
252
207
|
let totalFatalErrorCount = 0;
|
|
@@ -262,24 +217,20 @@ class ESLintLinter {
|
|
|
262
217
|
if (result.totalErrorCount) {
|
|
263
218
|
totalErrorCount += result.totalErrorCount;
|
|
264
219
|
totalComponentsWithErrorCount += 1;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
220
|
+
}
|
|
221
|
+
// @ts-ignore - missing from the @types/eslint lib
|
|
268
222
|
if (result.totalFatalErrorCount) {
|
|
269
223
|
totalFatalErrorCount += result.totalFatalErrorCount;
|
|
270
224
|
totalComponentsWithFatalErrorCount += 1;
|
|
271
225
|
}
|
|
272
|
-
|
|
273
226
|
if (result.totalFixableErrorCount) {
|
|
274
227
|
totalFixableErrorCount += result.totalFixableErrorCount;
|
|
275
228
|
totalComponentsWithFixableErrorCount += 1;
|
|
276
229
|
}
|
|
277
|
-
|
|
278
230
|
if (result.totalFixableWarningCount) {
|
|
279
231
|
totalFixableWarningCount += result.totalFixableWarningCount;
|
|
280
232
|
totalComponentsWithFixableWarningCount += 1;
|
|
281
233
|
}
|
|
282
|
-
|
|
283
234
|
if (result.totalWarningCount) {
|
|
284
235
|
totalWarningCount += result.totalWarningCount;
|
|
285
236
|
totalComponentsWithWarningCount += 1;
|
|
@@ -299,29 +250,24 @@ class ESLintLinter {
|
|
|
299
250
|
totalComponentsWithWarningCount
|
|
300
251
|
};
|
|
301
252
|
}
|
|
253
|
+
|
|
302
254
|
/**
|
|
303
255
|
* Create the eslint instance by options that was already merged with context
|
|
304
256
|
* @param options
|
|
305
257
|
* @param ESLintModule
|
|
306
258
|
* @returns
|
|
307
259
|
*/
|
|
308
|
-
|
|
309
|
-
|
|
310
260
|
createEslint(options, ESLintModule) {
|
|
311
261
|
// eslint-disable-next-line no-new
|
|
312
262
|
if (ESLintModule) new ESLintModule.ESLint(options);
|
|
313
263
|
return new (_eslint().ESLint)(options);
|
|
314
264
|
}
|
|
315
|
-
|
|
316
265
|
version() {
|
|
317
266
|
if (this.ESLint) return this.ESLint.version;
|
|
318
267
|
return _eslint().ESLint.version;
|
|
319
268
|
}
|
|
320
|
-
|
|
321
269
|
}
|
|
322
|
-
|
|
323
270
|
exports.ESLintLinter = ESLintLinter;
|
|
324
|
-
|
|
325
271
|
function getCacheDir(rootDir) {
|
|
326
272
|
return _path().default.join(rootDir, 'node_modules', '.cache');
|
|
327
273
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ESLintLinter","constructor","logger","options","ESLint","displayConfig","JSON","stringify","lint","context","longProcessLogger","createLongProcessLogger","components","length","eslint","createEslint","config","tsConfig","rootDir","tsConfigPath","createTempTsConfigFile","envRuntime","id","overrideConfig","parserOptions","project","resultsP","mapSeries","component","logProgress","toString","filesP","filesystem","files","map","file","extensions","includes","extname","undefined","path","compact","Promise","all","lintResults","lintFiles","fix","ESLintLib","outputFixes","results","flatten","formatter","loadFormatter","output","format","totalErrorCount","totalFatalErrorCount","totalFixableErrorCount","totalFixableWarningCount","totalWarningCount","componentsResults","computeComponentResultsWithTotals","totalComponentsWithErrorCount","totalComponentsWithFatalErrorCount","totalComponentsWithFixableErrorCount","totalComponentsWithFixableWarningCount","totalComponentsWithWarningCount","computeManyComponentsTotals","errors","envId","newTsConfig","include","includedPath","exclude","excludedPath","cacheDir","getCacheDir","hash","objectHash","tempTsConfigPath","join","fs","existsSync","outputJSONSync","spaces","result","errorCount","fatalErrorCount","fixableErrorCount","fixableWarningCount","warningCount","filePath","messages","raw","forEach","ESLintModule","version"],"sources":["eslint.linter.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport { flatten, compact } from 'lodash';\nimport { Linter, LinterContext, LintResults, ComponentLintResult } from '@teambit/linter';\nimport { ESLint as ESLintLib } from 'eslint';\nimport mapSeries from 'p-map-series';\nimport objectHash from 'object-hash';\nimport { Logger } from '@teambit/logger';\nimport { ESLintOptions } from './eslint.main.runtime';\n\nexport class ESLintLinter implements Linter {\n constructor(\n private logger: Logger,\n\n private options: ESLintOptions,\n\n /**\n * reference to the eslint module.\n */\n private ESLint?: any\n ) {}\n\n displayName = 'ESlint';\n\n displayConfig() {\n return JSON.stringify(this.options, null, 2);\n }\n\n async lint(context: LinterContext): Promise<LintResults> {\n const longProcessLogger = this.logger.createLongProcessLogger('linting components', context.components.length);\n const eslint = this.createEslint(this.options.config, this.ESLint);\n if (this.options.tsConfig && context.rootDir) {\n const tsConfigPath = this.createTempTsConfigFile(context.rootDir, context.envRuntime.id, this.options.tsConfig);\n if (this.options?.config?.overrideConfig?.parserOptions) {\n this.options.config.overrideConfig.parserOptions.project = tsConfigPath;\n }\n }\n const resultsP = mapSeries(context.components, async (component) => {\n longProcessLogger.logProgress(component.id.toString());\n const filesP = component.filesystem.files.map(async (file) => {\n // TODO: now that we moved to lint files, maybe it's not required anymore\n // The eslint api will not ignore extensions by default when using lintText, so we do it manually\n if (!this.options.extensions?.includes(file.extname)) return undefined;\n return file.path;\n });\n\n const files = compact(await Promise.all(filesP));\n const lintResults = await eslint.lintFiles(files);\n\n if (eslint && this.options.config.fix && lintResults) {\n await ESLintLib.outputFixes(lintResults);\n }\n\n const results: ESLintLib.LintResult[] = compact(flatten(lintResults));\n const formatter = await eslint.loadFormatter(this.options.formatter || 'stylish');\n const output = formatter.format(results);\n const {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n componentsResults,\n } = this.computeComponentResultsWithTotals(results);\n\n return {\n component,\n output,\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n results: componentsResults,\n };\n });\n\n const results = (await resultsP) as any as ComponentLintResult[];\n const {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n totalComponentsWithErrorCount,\n totalComponentsWithFatalErrorCount,\n totalComponentsWithFixableErrorCount,\n totalComponentsWithFixableWarningCount,\n totalComponentsWithWarningCount,\n } = this.computeManyComponentsTotals(results);\n\n return {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n totalComponentsWithErrorCount,\n totalComponentsWithFatalErrorCount,\n totalComponentsWithFixableErrorCount,\n totalComponentsWithFixableWarningCount,\n totalComponentsWithWarningCount,\n results,\n errors: [],\n };\n }\n\n private createTempTsConfigFile(rootDir: string, envId: string, tsConfig: Record<string, any>): string {\n const newTsConfig = {\n ...tsConfig,\n };\n if (tsConfig.include) {\n newTsConfig.include = tsConfig.include.map((includedPath) => `../../${includedPath}`);\n }\n if (tsConfig.exclude) {\n newTsConfig.exclude = tsConfig.exclude.map((excludedPath) => `../../${excludedPath}`);\n }\n const cacheDir = getCacheDir(rootDir);\n const hash = objectHash(newTsConfig);\n // We save the tsconfig with hash here to avoid creating unnecessary tsconfig files\n // this is very important as eslint will be able to cache the tsconfig file and will not need to create another program\n // this affects performance dramatically\n const tempTsConfigPath = path.join(cacheDir, `bit.tsconfig.eslint.${hash}.json`);\n if (!fs.existsSync(tempTsConfigPath)) {\n fs.outputJSONSync(tempTsConfigPath, newTsConfig, { spaces: 2 });\n }\n return tempTsConfigPath;\n }\n\n private computeComponentResultsWithTotals(results: ESLintLib.LintResult[]) {\n let totalErrorCount = 0;\n let totalFatalErrorCount = 0;\n let totalFixableErrorCount = 0;\n let totalFixableWarningCount = 0;\n let totalWarningCount = 0;\n const componentsResults = results.map((result) => {\n totalErrorCount += result.errorCount ?? 0;\n // @ts-ignore - missing from the @types/eslint lib\n totalFatalErrorCount += result.fatalErrorCount ?? 0;\n totalFixableErrorCount += result.fixableErrorCount ?? 0;\n totalFixableWarningCount += result.fixableWarningCount ?? 0;\n totalWarningCount += result.warningCount ?? 0;\n return {\n filePath: result.filePath,\n errorCount: result.errorCount,\n // @ts-ignore - missing from the @types/eslint lib\n fatalErrorCount: result.fatalErrorCount,\n fixableErrorCount: result.fixableErrorCount,\n fixableWarningCount: result.fixableWarningCount,\n warningCount: result.warningCount,\n messages: result.messages,\n raw: result,\n };\n });\n return {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n componentsResults,\n };\n }\n\n private computeManyComponentsTotals(componentsResults: ComponentLintResult[]) {\n let totalErrorCount = 0;\n let totalFatalErrorCount = 0;\n let totalFixableErrorCount = 0;\n let totalFixableWarningCount = 0;\n let totalWarningCount = 0;\n let totalComponentsWithErrorCount = 0;\n let totalComponentsWithFatalErrorCount = 0;\n let totalComponentsWithFixableErrorCount = 0;\n let totalComponentsWithFixableWarningCount = 0;\n let totalComponentsWithWarningCount = 0;\n\n componentsResults.forEach((result) => {\n if (result.totalErrorCount) {\n totalErrorCount += result.totalErrorCount;\n totalComponentsWithErrorCount += 1;\n }\n // @ts-ignore - missing from the @types/eslint lib\n if (result.totalFatalErrorCount) {\n totalFatalErrorCount += result.totalFatalErrorCount;\n totalComponentsWithFatalErrorCount += 1;\n }\n if (result.totalFixableErrorCount) {\n totalFixableErrorCount += result.totalFixableErrorCount;\n totalComponentsWithFixableErrorCount += 1;\n }\n if (result.totalFixableWarningCount) {\n totalFixableWarningCount += result.totalFixableWarningCount;\n totalComponentsWithFixableWarningCount += 1;\n }\n if (result.totalWarningCount) {\n totalWarningCount += result.totalWarningCount;\n totalComponentsWithWarningCount += 1;\n }\n });\n return {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n componentsResults,\n totalComponentsWithErrorCount,\n totalComponentsWithFatalErrorCount,\n totalComponentsWithFixableErrorCount,\n totalComponentsWithFixableWarningCount,\n totalComponentsWithWarningCount,\n };\n }\n\n /**\n * Create the eslint instance by options that was already merged with context\n * @param options\n * @param ESLintModule\n * @returns\n */\n private createEslint(options: ESLintLib.Options, ESLintModule?: any): ESLintLib {\n // eslint-disable-next-line no-new\n if (ESLintModule) new ESLintModule.ESLint(options);\n return new ESLintLib(options);\n }\n\n version() {\n if (this.ESLint) return this.ESLint.version;\n return ESLintLib.version;\n }\n}\n\nfunction getCacheDir(rootDir): string {\n return path.join(rootDir, 'node_modules', '.cache');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA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oCATK;MAULC,sCAVK;MAWLC;IAXK,CAAP;EAaD;EAED;AACF;AACA;AACA;AACA;AACA;;;EACUnD,YAAY,CAACZ,OAAD,EAA6B4F,YAA7B,EAA4D;IAC9E;IACA,IAAIA,YAAJ,EAAkB,IAAIA,YAAY,CAAC3F,MAAjB,CAAwBD,OAAxB;IAClB,OAAO,KAAI4C,gBAAJ,EAAc5C,OAAd,CAAP;EACD;;EAED6F,OAAO,GAAG;IACR,IAAI,KAAK5F,MAAT,EAAiB,OAAO,KAAKA,MAAL,CAAY4F,OAAnB;IACjB,OAAOjD,gBAAA,CAAUiD,OAAjB;EACD;;AA3NyC;;;;AA8N5C,SAASpB,WAAT,CAAqB1D,OAArB,EAAsC;EACpC,OAAOsB,eAAA,CAAKwC,IAAL,CAAU9D,OAAV,EAAmB,cAAnB,EAAmC,QAAnC,CAAP;AACD"}
|
|
1
|
+
{"version":3,"names":["ESLintLinter","constructor","logger","options","ESLint","displayConfig","JSON","stringify","lint","context","longProcessLogger","createLongProcessLogger","components","length","eslint","createEslint","config","tsConfig","rootDir","tsConfigPath","createTempTsConfigFile","envRuntime","id","overrideConfig","parserOptions","project","resultsP","mapSeries","component","logProgress","toString","filesP","filesystem","files","map","file","extensions","includes","extname","undefined","path","compact","Promise","all","lintResults","lintFiles","fix","ESLintLib","outputFixes","results","flatten","formatter","loadFormatter","output","format","totalErrorCount","totalFatalErrorCount","totalFixableErrorCount","totalFixableWarningCount","totalWarningCount","componentsResults","computeComponentResultsWithTotals","totalComponentsWithErrorCount","totalComponentsWithFatalErrorCount","totalComponentsWithFixableErrorCount","totalComponentsWithFixableWarningCount","totalComponentsWithWarningCount","computeManyComponentsTotals","errors","envId","newTsConfig","include","includedPath","exclude","excludedPath","cacheDir","getCacheDir","hash","objectHash","tempTsConfigPath","join","fs","existsSync","outputJSONSync","spaces","result","errorCount","fatalErrorCount","fixableErrorCount","fixableWarningCount","warningCount","filePath","messages","raw","forEach","ESLintModule","version"],"sources":["eslint.linter.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport { flatten, compact } from 'lodash';\nimport { Linter, LinterContext, LintResults, ComponentLintResult } from '@teambit/linter';\nimport { ESLint as ESLintLib } from 'eslint';\nimport mapSeries from 'p-map-series';\nimport objectHash from 'object-hash';\nimport { Logger } from '@teambit/logger';\nimport { ESLintOptions } from './eslint.main.runtime';\n\nexport class ESLintLinter implements Linter {\n constructor(\n private logger: Logger,\n\n private options: ESLintOptions,\n\n /**\n * reference to the eslint module.\n */\n private ESLint?: any\n ) {}\n\n displayName = 'ESlint';\n\n displayConfig() {\n return JSON.stringify(this.options, null, 2);\n }\n\n async lint(context: LinterContext): Promise<LintResults> {\n const longProcessLogger = this.logger.createLongProcessLogger('linting components', context.components.length);\n const eslint = this.createEslint(this.options.config, this.ESLint);\n if (this.options.tsConfig && context.rootDir) {\n const tsConfigPath = this.createTempTsConfigFile(context.rootDir, context.envRuntime.id, this.options.tsConfig);\n if (this.options?.config?.overrideConfig?.parserOptions) {\n this.options.config.overrideConfig.parserOptions.project = tsConfigPath;\n }\n }\n const resultsP = mapSeries(context.components, async (component) => {\n longProcessLogger.logProgress(component.id.toString());\n const filesP = component.filesystem.files.map(async (file) => {\n // TODO: now that we moved to lint files, maybe it's not required anymore\n // The eslint api will not ignore extensions by default when using lintText, so we do it manually\n if (!this.options.extensions?.includes(file.extname)) return undefined;\n return file.path;\n });\n\n const files = compact(await Promise.all(filesP));\n const lintResults = await eslint.lintFiles(files);\n\n if (eslint && this.options.config.fix && lintResults) {\n await ESLintLib.outputFixes(lintResults);\n }\n\n const results: ESLintLib.LintResult[] = compact(flatten(lintResults));\n const formatter = await eslint.loadFormatter(this.options.formatter || 'stylish');\n const output = formatter.format(results);\n const {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n componentsResults,\n } = this.computeComponentResultsWithTotals(results);\n\n return {\n component,\n output,\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n results: componentsResults,\n };\n });\n\n const results = (await resultsP) as any as ComponentLintResult[];\n const {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n totalComponentsWithErrorCount,\n totalComponentsWithFatalErrorCount,\n totalComponentsWithFixableErrorCount,\n totalComponentsWithFixableWarningCount,\n totalComponentsWithWarningCount,\n } = this.computeManyComponentsTotals(results);\n\n return {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n totalComponentsWithErrorCount,\n totalComponentsWithFatalErrorCount,\n totalComponentsWithFixableErrorCount,\n totalComponentsWithFixableWarningCount,\n totalComponentsWithWarningCount,\n results,\n errors: [],\n };\n }\n\n private createTempTsConfigFile(rootDir: string, envId: string, tsConfig: Record<string, any>): string {\n const newTsConfig = {\n ...tsConfig,\n };\n if (tsConfig.include) {\n newTsConfig.include = tsConfig.include.map((includedPath) => `../../${includedPath}`);\n }\n if (tsConfig.exclude) {\n newTsConfig.exclude = tsConfig.exclude.map((excludedPath) => `../../${excludedPath}`);\n }\n const cacheDir = getCacheDir(rootDir);\n const hash = objectHash(newTsConfig);\n // We save the tsconfig with hash here to avoid creating unnecessary tsconfig files\n // this is very important as eslint will be able to cache the tsconfig file and will not need to create another program\n // this affects performance dramatically\n const tempTsConfigPath = path.join(cacheDir, `bit.tsconfig.eslint.${hash}.json`);\n if (!fs.existsSync(tempTsConfigPath)) {\n fs.outputJSONSync(tempTsConfigPath, newTsConfig, { spaces: 2 });\n }\n return tempTsConfigPath;\n }\n\n private computeComponentResultsWithTotals(results: ESLintLib.LintResult[]) {\n let totalErrorCount = 0;\n let totalFatalErrorCount = 0;\n let totalFixableErrorCount = 0;\n let totalFixableWarningCount = 0;\n let totalWarningCount = 0;\n const componentsResults = results.map((result) => {\n totalErrorCount += result.errorCount ?? 0;\n // @ts-ignore - missing from the @types/eslint lib\n totalFatalErrorCount += result.fatalErrorCount ?? 0;\n totalFixableErrorCount += result.fixableErrorCount ?? 0;\n totalFixableWarningCount += result.fixableWarningCount ?? 0;\n totalWarningCount += result.warningCount ?? 0;\n return {\n filePath: result.filePath,\n errorCount: result.errorCount,\n // @ts-ignore - missing from the @types/eslint lib\n fatalErrorCount: result.fatalErrorCount,\n fixableErrorCount: result.fixableErrorCount,\n fixableWarningCount: result.fixableWarningCount,\n warningCount: result.warningCount,\n messages: result.messages,\n raw: result,\n };\n });\n return {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n componentsResults,\n };\n }\n\n private computeManyComponentsTotals(componentsResults: ComponentLintResult[]) {\n let totalErrorCount = 0;\n let totalFatalErrorCount = 0;\n let totalFixableErrorCount = 0;\n let totalFixableWarningCount = 0;\n let totalWarningCount = 0;\n let totalComponentsWithErrorCount = 0;\n let totalComponentsWithFatalErrorCount = 0;\n let totalComponentsWithFixableErrorCount = 0;\n let totalComponentsWithFixableWarningCount = 0;\n let totalComponentsWithWarningCount = 0;\n\n componentsResults.forEach((result) => {\n if (result.totalErrorCount) {\n totalErrorCount += result.totalErrorCount;\n totalComponentsWithErrorCount += 1;\n }\n // @ts-ignore - missing from the @types/eslint lib\n if (result.totalFatalErrorCount) {\n totalFatalErrorCount += result.totalFatalErrorCount;\n totalComponentsWithFatalErrorCount += 1;\n }\n if (result.totalFixableErrorCount) {\n totalFixableErrorCount += result.totalFixableErrorCount;\n totalComponentsWithFixableErrorCount += 1;\n }\n if (result.totalFixableWarningCount) {\n totalFixableWarningCount += result.totalFixableWarningCount;\n totalComponentsWithFixableWarningCount += 1;\n }\n if (result.totalWarningCount) {\n totalWarningCount += result.totalWarningCount;\n totalComponentsWithWarningCount += 1;\n }\n });\n return {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n componentsResults,\n totalComponentsWithErrorCount,\n totalComponentsWithFatalErrorCount,\n totalComponentsWithFixableErrorCount,\n totalComponentsWithFixableWarningCount,\n totalComponentsWithWarningCount,\n };\n }\n\n /**\n * Create the eslint instance by options that was already merged with context\n * @param options\n * @param ESLintModule\n * @returns\n */\n private createEslint(options: ESLintLib.Options, ESLintModule?: any): ESLintLib {\n // eslint-disable-next-line no-new\n if (ESLintModule) new ESLintModule.ESLint(options);\n return new ESLintLib(options);\n }\n\n version() {\n if (this.ESLint) return this.ESLint.version;\n return ESLintLib.version;\n }\n}\n\nfunction getCacheDir(rootDir): string {\n return path.join(rootDir, 'node_modules', '.cache');\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAqC;AAAA;AAI9B,MAAMA,YAAY,CAAmB;EAC1CC,WAAW,CACDC,MAAc,EAEdC,OAAsB;EAE9B;AACJ;AACA;EACYC,MAAY,EACpB;IAAA,KARQF,MAAc,GAAdA,MAAc;IAAA,KAEdC,OAAsB,GAAtBA,OAAsB;IAAA,KAKtBC,MAAY,GAAZA,MAAY;IAAA,qDAGR,QAAQ;EAFnB;EAIHC,aAAa,GAAG;IACd,OAAOC,IAAI,CAACC,SAAS,CAAC,IAAI,CAACJ,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;EAC9C;EAEA,MAAMK,IAAI,CAACC,OAAsB,EAAwB;IACvD,MAAMC,iBAAiB,GAAG,IAAI,CAACR,MAAM,CAACS,uBAAuB,CAAC,oBAAoB,EAAEF,OAAO,CAACG,UAAU,CAACC,MAAM,CAAC;IAC9G,MAAMC,MAAM,GAAG,IAAI,CAACC,YAAY,CAAC,IAAI,CAACZ,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,sBAAsB;QACvDO,oCAAoC,IAAI,CAAC;MAC3C;MACA,IAAIqB,MAAM,CAAC3B,wBAAwB,EAAE;QACnCA,wBAAwB,IAAI2B,MAAM,CAAC3B,wBAAwB;QAC3DO,sCAAsC,IAAI,CAAC;MAC7C;MACA,IAAIoB,MAAM,CAAC1B,iBAAiB,EAAE;QAC5BA,iBAAiB,IAAI0B,MAAM,CAAC1B,iBAAiB;QAC7CO,+BAA+B,IAAI,CAAC;MACtC;IACF,CAAC,CAAC;IACF,OAAO;MACLX,eAAe;MACfC,oBAAoB;MACpBC,sBAAsB;MACtBC,wBAAwB;MACxBC,iBAAiB;MACjBC,iBAAiB;MACjBE,6BAA6B;MAC7BC,kCAAkC;MAClCC,oCAAoC;MACpCC,sCAAsC;MACtCC;IACF,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACUnD,YAAY,CAACZ,OAA0B,EAAE4F,YAAkB,EAAa;IAC9E;IACA,IAAIA,YAAY,EAAE,IAAIA,YAAY,CAAC3F,MAAM,CAACD,OAAO,CAAC;IAClD,OAAO,KAAI4C,gBAAS,EAAC5C,OAAO,CAAC;EAC/B;EAEA6F,OAAO,GAAG;IACR,IAAI,IAAI,CAAC5F,MAAM,EAAE,OAAO,IAAI,CAACA,MAAM,CAAC4F,OAAO;IAC3C,OAAOjD,gBAAS,CAACiD,OAAO;EAC1B;AACF;AAAC;AAED,SAASpB,WAAW,CAAC1D,OAAO,EAAU;EACpC,OAAOsB,eAAI,CAACwC,IAAI,CAAC9D,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC;AACrD"}
|
|
@@ -1,88 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.ESLintMain = void 0;
|
|
13
10
|
exports.runTransformersWithContext = runTransformersWithContext;
|
|
14
|
-
|
|
15
11
|
function _defineProperty2() {
|
|
16
12
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
13
|
_defineProperty2 = function () {
|
|
19
14
|
return data;
|
|
20
15
|
};
|
|
21
|
-
|
|
22
16
|
return data;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
function _cli() {
|
|
26
19
|
const data = require("@teambit/cli");
|
|
27
|
-
|
|
28
20
|
_cli = function () {
|
|
29
21
|
return data;
|
|
30
22
|
};
|
|
31
|
-
|
|
32
23
|
return data;
|
|
33
24
|
}
|
|
34
|
-
|
|
35
25
|
function _logger() {
|
|
36
26
|
const data = require("@teambit/logger");
|
|
37
|
-
|
|
38
27
|
_logger = function () {
|
|
39
28
|
return data;
|
|
40
29
|
};
|
|
41
|
-
|
|
42
30
|
return data;
|
|
43
31
|
}
|
|
44
|
-
|
|
45
32
|
function _defenderEslint() {
|
|
46
33
|
const data = require("@teambit/defender.eslint.config-mutator");
|
|
47
|
-
|
|
48
34
|
_defenderEslint = function () {
|
|
49
35
|
return data;
|
|
50
36
|
};
|
|
51
|
-
|
|
52
37
|
return data;
|
|
53
38
|
}
|
|
54
|
-
|
|
55
39
|
function _eslint() {
|
|
56
40
|
const data = require("./eslint.aspect");
|
|
57
|
-
|
|
58
41
|
_eslint = function () {
|
|
59
42
|
return data;
|
|
60
43
|
};
|
|
61
|
-
|
|
62
44
|
return data;
|
|
63
45
|
}
|
|
64
|
-
|
|
65
46
|
function _eslint2() {
|
|
66
47
|
const data = require("./eslint.linter");
|
|
67
|
-
|
|
68
48
|
_eslint2 = function () {
|
|
69
49
|
return data;
|
|
70
50
|
};
|
|
71
|
-
|
|
72
51
|
return data;
|
|
73
52
|
}
|
|
74
|
-
|
|
75
53
|
class ESLintMain {
|
|
76
54
|
constructor(logger) {
|
|
77
55
|
this.logger = logger;
|
|
78
56
|
}
|
|
57
|
+
|
|
79
58
|
/**
|
|
80
59
|
* create a eslint linter instance.
|
|
81
60
|
* @param options eslint options.
|
|
82
61
|
* @param ESLintModule reference to an `eslint` module.
|
|
83
62
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
63
|
createLinter(context, options, transformers = [], ESLintModule) {
|
|
87
64
|
const mergedOptions = getOptions(options, context);
|
|
88
65
|
const configMutator = new (_defenderEslint().EslintConfigMutator)(mergedOptions);
|
|
@@ -92,24 +69,19 @@ class ESLintMain {
|
|
|
92
69
|
const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);
|
|
93
70
|
return new (_eslint2().ESLintLinter)(this.logger, afterMutation.raw, ESLintModule);
|
|
94
71
|
}
|
|
95
|
-
|
|
96
72
|
static async provider([loggerExt]) {
|
|
97
73
|
const logger = loggerExt.createLogger(_eslint().ESLintAspect.id);
|
|
98
74
|
return new ESLintMain(logger);
|
|
99
75
|
}
|
|
100
|
-
|
|
101
76
|
}
|
|
102
|
-
|
|
103
77
|
exports.ESLintMain = ESLintMain;
|
|
104
78
|
(0, _defineProperty2().default)(ESLintMain, "runtime", _cli().MainRuntime);
|
|
105
79
|
(0, _defineProperty2().default)(ESLintMain, "dependencies", [_logger().LoggerAspect]);
|
|
106
|
-
|
|
107
80
|
_eslint().ESLintAspect.addRuntime(ESLintMain);
|
|
81
|
+
|
|
108
82
|
/**
|
|
109
83
|
* get options for eslint.
|
|
110
84
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
85
|
function getOptions(options, context) {
|
|
114
86
|
const mergedConfig = {
|
|
115
87
|
// @ts-ignore - this is a bug in the @types/eslint types
|
|
@@ -125,7 +97,6 @@ function getOptions(options, context) {
|
|
|
125
97
|
extensions: context.extensionFormats
|
|
126
98
|
});
|
|
127
99
|
}
|
|
128
|
-
|
|
129
100
|
function runTransformersWithContext(config, transformers = [], context) {
|
|
130
101
|
if (!Array.isArray(transformers)) return config;
|
|
131
102
|
const newConfig = transformers.reduce((acc, transformer) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ESLintMain","constructor","logger","createLinter","context","options","transformers","ESLintModule","mergedOptions","getOptions","configMutator","EslintConfigMutator","transformerContext","fix","afterMutation","runTransformersWithContext","clone","ESLintLinter","raw","provider","loggerExt","createLogger","ESLintAspect","id","MainRuntime","LoggerAspect","addRuntime","mergedConfig","overrideConfig","config","extensions","extensionFormats","useEslintrc","cwd","pluginPath","fixTypes","Object","assign","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["eslint.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\n// import { Linter as ESLinter, ESLint as ESLintLib } from 'eslint';\nimport { ESLint as ESLintLib } from 'eslint';\nimport { Linter, LinterContext } from '@teambit/linter';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { EslintConfigMutator } from '@teambit/defender.eslint.config-mutator';\nimport { ESLintAspect } from './eslint.aspect';\nimport { ESLintLinter } from './eslint.linter';\n\nexport type ESLintOptions = {\n /**\n * linter config for eslint.\n */\n // config: ESLinter.Config;\n config: ESLintLib.Options;\n\n /**\n * specify to path to resolve eslint plugins from.\n */\n pluginPath?: string;\n\n /**\n * decide the formatter for the CLI output.\n */\n formatter?: string;\n\n /**\n * file types to lint.\n */\n extensions?: string[];\n\n // TODO: improve type\n /**\n * typescript config for eslint.\n * If you pass this, bit will auto generate a temp config file in `node_modules/.cache` and pass it to eslint.\n * In case you have include/exclude props in the tsconfig, they will be changed to handle the fact that they are inside the node_modules/.cache folder.\n * a `../../` will be added to the beginning of the path.\n */\n tsConfig?: Record<string, any>;\n};\n\nexport type EslintConfigTransformContext = {\n fix: boolean;\n};\n\nexport type EslintConfigTransformer = (\n config: EslintConfigMutator,\n context: EslintConfigTransformContext\n) => EslintConfigMutator;\n\nexport class ESLintMain {\n constructor(private logger: Logger) {}\n\n /**\n * create a eslint linter instance.\n * @param options eslint options.\n * @param ESLintModule reference to an `eslint` module.\n */\n createLinter(\n context: LinterContext,\n options: ESLintOptions,\n transformers: EslintConfigTransformer[] = [],\n ESLintModule?: any\n ): Linter {\n const mergedOptions = getOptions(options, context);\n const configMutator = new EslintConfigMutator(mergedOptions);\n const transformerContext: EslintConfigTransformContext = { fix: !!context.fix };\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n\n return new ESLintLinter(this.logger, afterMutation.raw, ESLintModule);\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [LoggerAspect];\n\n static async provider([loggerExt]: [LoggerMain]): Promise<ESLintMain> {\n const logger = loggerExt.createLogger(ESLintAspect.id);\n return new ESLintMain(logger);\n }\n}\n\nESLintAspect.addRuntime(ESLintMain);\n\n/**\n * get options for eslint.\n */\nfunction getOptions(options: ESLintOptions, context: LinterContext): ESLintOptions {\n const mergedConfig: ESLintLib.Options = {\n // @ts-ignore - this is a bug in the @types/eslint types\n overrideConfig: options.config,\n extensions: context.extensionFormats,\n useEslintrc: false,\n cwd: options.pluginPath,\n fix: !!context.fix,\n fixTypes: context.fixTypes,\n };\n return Object.assign({}, options, { config: mergedConfig, extensions: context.extensionFormats });\n}\n\nexport function runTransformersWithContext(\n config: EslintConfigMutator,\n transformers: EslintConfigTransformer[] = [],\n context: EslintConfigTransformContext\n): EslintConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["ESLintMain","constructor","logger","createLinter","context","options","transformers","ESLintModule","mergedOptions","getOptions","configMutator","EslintConfigMutator","transformerContext","fix","afterMutation","runTransformersWithContext","clone","ESLintLinter","raw","provider","loggerExt","createLogger","ESLintAspect","id","MainRuntime","LoggerAspect","addRuntime","mergedConfig","overrideConfig","config","extensions","extensionFormats","useEslintrc","cwd","pluginPath","fixTypes","Object","assign","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["eslint.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\n// import { Linter as ESLinter, ESLint as ESLintLib } from 'eslint';\nimport { ESLint as ESLintLib } from 'eslint';\nimport { Linter, LinterContext } from '@teambit/linter';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { EslintConfigMutator } from '@teambit/defender.eslint.config-mutator';\nimport { ESLintAspect } from './eslint.aspect';\nimport { ESLintLinter } from './eslint.linter';\n\nexport type ESLintOptions = {\n /**\n * linter config for eslint.\n */\n // config: ESLinter.Config;\n config: ESLintLib.Options;\n\n /**\n * specify to path to resolve eslint plugins from.\n */\n pluginPath?: string;\n\n /**\n * decide the formatter for the CLI output.\n */\n formatter?: string;\n\n /**\n * file types to lint.\n */\n extensions?: string[];\n\n // TODO: improve type\n /**\n * typescript config for eslint.\n * If you pass this, bit will auto generate a temp config file in `node_modules/.cache` and pass it to eslint.\n * In case you have include/exclude props in the tsconfig, they will be changed to handle the fact that they are inside the node_modules/.cache folder.\n * a `../../` will be added to the beginning of the path.\n */\n tsConfig?: Record<string, any>;\n};\n\nexport type EslintConfigTransformContext = {\n fix: boolean;\n};\n\nexport type EslintConfigTransformer = (\n config: EslintConfigMutator,\n context: EslintConfigTransformContext\n) => EslintConfigMutator;\n\nexport class ESLintMain {\n constructor(private logger: Logger) {}\n\n /**\n * create a eslint linter instance.\n * @param options eslint options.\n * @param ESLintModule reference to an `eslint` module.\n */\n createLinter(\n context: LinterContext,\n options: ESLintOptions,\n transformers: EslintConfigTransformer[] = [],\n ESLintModule?: any\n ): Linter {\n const mergedOptions = getOptions(options, context);\n const configMutator = new EslintConfigMutator(mergedOptions);\n const transformerContext: EslintConfigTransformContext = { fix: !!context.fix };\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n\n return new ESLintLinter(this.logger, afterMutation.raw, ESLintModule);\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [LoggerAspect];\n\n static async provider([loggerExt]: [LoggerMain]): Promise<ESLintMain> {\n const logger = loggerExt.createLogger(ESLintAspect.id);\n return new ESLintMain(logger);\n }\n}\n\nESLintAspect.addRuntime(ESLintMain);\n\n/**\n * get options for eslint.\n */\nfunction getOptions(options: ESLintOptions, context: LinterContext): ESLintOptions {\n const mergedConfig: ESLintLib.Options = {\n // @ts-ignore - this is a bug in the @types/eslint types\n overrideConfig: options.config,\n extensions: context.extensionFormats,\n useEslintrc: false,\n cwd: options.pluginPath,\n fix: !!context.fix,\n fixTypes: context.fixTypes,\n };\n return Object.assign({}, options, { config: mergedConfig, extensions: context.extensionFormats });\n}\n\nexport function runTransformersWithContext(\n config: EslintConfigMutator,\n transformers: EslintConfigTransformer[] = [],\n context: EslintConfigTransformContext\n): EslintConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AA2CO,MAAMA,UAAU,CAAC;EACtBC,WAAW,CAASC,MAAc,EAAE;IAAA,KAAhBA,MAAc,GAAdA,MAAc;EAAG;;EAErC;AACF;AACA;AACA;AACA;EACEC,YAAY,CACVC,OAAsB,EACtBC,OAAsB,EACtBC,YAAuC,GAAG,EAAE,EAC5CC,YAAkB,EACV;IACR,MAAMC,aAAa,GAAGC,UAAU,CAACJ,OAAO,EAAED,OAAO,CAAC;IAClD,MAAMM,aAAa,GAAG,KAAIC,qCAAmB,EAACH,aAAa,CAAC;IAC5D,MAAMI,kBAAgD,GAAG;MAAEC,GAAG,EAAE,CAAC,CAACT,OAAO,CAACS;IAAI,CA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SAAS,GAAGlC,YAAY,CAACmC,MAAM,CAAC,CAACC,GAAG,EAAEC,WAAW,KAAK;IAC1D,OAAOA,WAAW,CAACD,GAAG,EAAEtC,OAAO,CAAC;EAClC,CAAC,EAAEyB,MAAM,CAAC;EACV,OAAOW,SAAS;AAClB"}
|
package/dist/index.js
CHANGED
|
@@ -10,19 +10,14 @@ Object.defineProperty(exports, "ESLintAspect", {
|
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
exports.default = void 0;
|
|
13
|
-
|
|
14
13
|
function _eslint() {
|
|
15
14
|
const data = require("./eslint.aspect");
|
|
16
|
-
|
|
17
15
|
_eslint = function () {
|
|
18
16
|
return data;
|
|
19
17
|
};
|
|
20
|
-
|
|
21
18
|
return data;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
var _default = _eslint().ESLintAspect;
|
|
25
|
-
|
|
26
21
|
exports.default = _default;
|
|
27
22
|
|
|
28
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ESLintAspect"],"sources":["index.ts"],"sourcesContent":["import { ESLintAspect } from './eslint.aspect';\n\nexport { ESLintAspect };\nexport type {\n ESLintMain,\n ESLintOptions,\n EslintConfigTransformContext,\n EslintConfigTransformer,\n} from './eslint.main.runtime';\nexport default ESLintAspect;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["ESLintAspect"],"sources":["index.ts"],"sourcesContent":["import { ESLintAspect } from './eslint.aspect';\n\nexport { ESLintAspect };\nexport type {\n ESLintMain,\n ESLintOptions,\n EslintConfigTransformContext,\n EslintConfigTransformer,\n} from './eslint.main.runtime';\nexport default ESLintAspect;\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA+C,eAShCA,sBAAY;AAAA"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/eslint",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.882",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/defender/eslint",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.defender",
|
|
8
8
|
"name": "eslint",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.882"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"eslint": "7.32.0",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@babel/runtime": "7.12.18",
|
|
18
18
|
"core-js": "^3.0.0",
|
|
19
19
|
"@teambit/harmony": "0.3.3",
|
|
20
|
-
"@teambit/linter": "0.0.
|
|
20
|
+
"@teambit/linter": "0.0.882",
|
|
21
21
|
"@teambit/logger": "0.0.684",
|
|
22
22
|
"@teambit/cli": "0.0.591",
|
|
23
23
|
"@teambit/defender.eslint.config-mutator": "0.0.91"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.882/dist/eslint.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.882/dist/eslint.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
Binary file
|