@teambit/eslint 0.0.858 → 0.0.859
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.linter.d.ts +1 -0
- package/dist/eslint.linter.js +136 -24
- package/dist/eslint.linter.js.map +1 -1
- package/dist/eslint.main.runtime.d.ts +7 -0
- package/dist/eslint.main.runtime.js.map +1 -1
- package/package-tar/teambit-eslint-0.0.859.tgz +0 -0
- package/package.json +10 -6
- package/{preview-1663645073615.js → preview-1663693322588.js} +2 -2
- package/package-tar/teambit-eslint-0.0.858.tgz +0 -0
package/dist/eslint.linter.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class ESLintLinter implements Linter {
|
|
|
16
16
|
displayName: string;
|
|
17
17
|
displayConfig(): string;
|
|
18
18
|
lint(context: LinterContext): Promise<LintResults>;
|
|
19
|
+
private createTempTsConfigFile;
|
|
19
20
|
private computeComponentResultsWithTotals;
|
|
20
21
|
private computeManyComponentsTotals;
|
|
21
22
|
/**
|
package/dist/eslint.linter.js
CHANGED
|
@@ -21,6 +21,26 @@ function _defineProperty2() {
|
|
|
21
21
|
return data;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
function _fsExtra() {
|
|
25
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
26
|
+
|
|
27
|
+
_fsExtra = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _path() {
|
|
35
|
+
const data = _interopRequireDefault(require("path"));
|
|
36
|
+
|
|
37
|
+
_path = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
24
44
|
function _lodash() {
|
|
25
45
|
const data = require("lodash");
|
|
26
46
|
|
|
@@ -51,6 +71,20 @@ function _pMapSeries() {
|
|
|
51
71
|
return data;
|
|
52
72
|
}
|
|
53
73
|
|
|
74
|
+
function _objectHash() {
|
|
75
|
+
const data = _interopRequireDefault(require("object-hash"));
|
|
76
|
+
|
|
77
|
+
_objectHash = function () {
|
|
78
|
+
return data;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
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
|
+
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
|
+
|
|
54
88
|
class ESLintLinter {
|
|
55
89
|
constructor(logger, options,
|
|
56
90
|
/**
|
|
@@ -69,28 +103,36 @@ class ESLintLinter {
|
|
|
69
103
|
|
|
70
104
|
async lint(context) {
|
|
71
105
|
const longProcessLogger = this.logger.createLongProcessLogger('linting components', context.components.length);
|
|
106
|
+
const eslint = this.createEslint(this.options.config, this.ESLint);
|
|
107
|
+
|
|
108
|
+
if (this.options.tsConfig && context.rootDir) {
|
|
109
|
+
var _this$options, _this$options$config, _this$options$config$;
|
|
110
|
+
|
|
111
|
+
const tsConfigPath = this.createTempTsConfigFile(context.rootDir, context.envRuntime.id, this.options.tsConfig);
|
|
112
|
+
|
|
113
|
+
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
|
+
this.options.config.overrideConfig.parserOptions.project = tsConfigPath;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
72
118
|
const resultsP = (0, _pMapSeries().default)(context.components, async component => {
|
|
73
119
|
longProcessLogger.logProgress(component.id.toString());
|
|
74
|
-
const eslint = this.createEslint(this.options.config, this.ESLint);
|
|
75
120
|
const filesP = component.filesystem.files.map(async file => {
|
|
76
121
|
var _this$options$extensi;
|
|
77
122
|
|
|
78
|
-
//
|
|
123
|
+
// TODO: now that we moved to lint files, maybe it's not required anymore
|
|
124
|
+
// The eslint api will not ignore extensions by default when using lintText, so we do it manually
|
|
79
125
|
if (!((_this$options$extensi = this.options.extensions) !== null && _this$options$extensi !== void 0 && _this$options$extensi.includes(file.extname))) return undefined;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
126
|
+
return file.path;
|
|
127
|
+
});
|
|
128
|
+
const files = (0, _lodash().compact)(await Promise.all(filesP));
|
|
129
|
+
const lintResults = await eslint.lintFiles(files);
|
|
85
130
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
131
|
+
if (eslint && this.options.config.fix && lintResults) {
|
|
132
|
+
await _eslint().ESLint.outputFixes(lintResults);
|
|
133
|
+
}
|
|
89
134
|
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
const files = await Promise.all(filesP);
|
|
93
|
-
const results = (0, _lodash().compact)((0, _lodash().flatten)(files));
|
|
135
|
+
const results = (0, _lodash().compact)((0, _lodash().flatten)(lintResults));
|
|
94
136
|
const formatter = await eslint.loadFormatter(this.options.formatter || 'stylish');
|
|
95
137
|
const output = formatter.format(results);
|
|
96
138
|
const {
|
|
@@ -118,7 +160,12 @@ class ESLintLinter {
|
|
|
118
160
|
totalFatalErrorCount,
|
|
119
161
|
totalFixableErrorCount,
|
|
120
162
|
totalFixableWarningCount,
|
|
121
|
-
totalWarningCount
|
|
163
|
+
totalWarningCount,
|
|
164
|
+
totalComponentsWithErrorCount,
|
|
165
|
+
totalComponentsWithFatalErrorCount,
|
|
166
|
+
totalComponentsWithFixableErrorCount,
|
|
167
|
+
totalComponentsWithFixableWarningCount,
|
|
168
|
+
totalComponentsWithWarningCount
|
|
122
169
|
} = this.computeManyComponentsTotals(results);
|
|
123
170
|
return {
|
|
124
171
|
totalErrorCount,
|
|
@@ -126,11 +173,45 @@ class ESLintLinter {
|
|
|
126
173
|
totalFixableErrorCount,
|
|
127
174
|
totalFixableWarningCount,
|
|
128
175
|
totalWarningCount,
|
|
176
|
+
totalComponentsWithErrorCount,
|
|
177
|
+
totalComponentsWithFatalErrorCount,
|
|
178
|
+
totalComponentsWithFixableErrorCount,
|
|
179
|
+
totalComponentsWithFixableWarningCount,
|
|
180
|
+
totalComponentsWithWarningCount,
|
|
129
181
|
results,
|
|
130
182
|
errors: []
|
|
131
183
|
};
|
|
132
184
|
}
|
|
133
185
|
|
|
186
|
+
createTempTsConfigFile(rootDir, envId, tsConfig) {
|
|
187
|
+
const newTsConfig = _objectSpread({}, tsConfig);
|
|
188
|
+
|
|
189
|
+
if (tsConfig.include) {
|
|
190
|
+
newTsConfig.include = tsConfig.include.map(includedPath => `../../${includedPath}`);
|
|
191
|
+
;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (tsConfig.exclude) {
|
|
195
|
+
newTsConfig.exclude = tsConfig.exclude.map(excludedPath => `../../${excludedPath}`);
|
|
196
|
+
;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const cacheDir = getCacheDir(rootDir);
|
|
200
|
+
const hash = (0, _objectHash().default)(newTsConfig); // We save the tsconfig with hash here to avoid creating unnecessary tsconfig files
|
|
201
|
+
// this is very important as eslint will be able to cache the tsconfig file and will not need to create another program
|
|
202
|
+
// this affects performance dramatically
|
|
203
|
+
|
|
204
|
+
const tempTsConfigPath = _path().default.join(cacheDir, `bit.tsconfig.eslint.${hash}.json`);
|
|
205
|
+
|
|
206
|
+
if (!_fsExtra().default.existsSync(tempTsConfigPath)) {
|
|
207
|
+
_fsExtra().default.outputJSONSync(tempTsConfigPath, newTsConfig, {
|
|
208
|
+
spaces: 2
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return tempTsConfigPath;
|
|
213
|
+
}
|
|
214
|
+
|
|
134
215
|
computeComponentResultsWithTotals(results) {
|
|
135
216
|
let totalErrorCount = 0;
|
|
136
217
|
let totalFatalErrorCount = 0;
|
|
@@ -174,15 +255,37 @@ class ESLintLinter {
|
|
|
174
255
|
let totalFixableErrorCount = 0;
|
|
175
256
|
let totalFixableWarningCount = 0;
|
|
176
257
|
let totalWarningCount = 0;
|
|
258
|
+
let totalComponentsWithErrorCount = 0;
|
|
259
|
+
let totalComponentsWithFatalErrorCount = 0;
|
|
260
|
+
let totalComponentsWithFixableErrorCount = 0;
|
|
261
|
+
let totalComponentsWithFixableWarningCount = 0;
|
|
262
|
+
let totalComponentsWithWarningCount = 0;
|
|
177
263
|
componentsResults.forEach(result => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
264
|
+
if (result.totalErrorCount) {
|
|
265
|
+
totalErrorCount += result.totalErrorCount;
|
|
266
|
+
totalComponentsWithErrorCount += 1;
|
|
267
|
+
} // @ts-ignore - missing from the @types/eslint lib
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
if (result.totalFatalErrorCount) {
|
|
271
|
+
totalFatalErrorCount += result.totalFatalErrorCount;
|
|
272
|
+
totalComponentsWithFatalErrorCount += 1;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (result.totalFixableErrorCount) {
|
|
276
|
+
totalFixableErrorCount += result.totalFixableErrorCount;
|
|
277
|
+
totalComponentsWithFixableErrorCount += 1;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (result.totalFixableWarningCount) {
|
|
281
|
+
totalFixableWarningCount += result.totalFixableWarningCount;
|
|
282
|
+
totalComponentsWithFixableWarningCount += 1;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (result.totalWarningCount) {
|
|
286
|
+
totalWarningCount += result.totalWarningCount;
|
|
287
|
+
totalComponentsWithWarningCount += 1;
|
|
288
|
+
}
|
|
186
289
|
});
|
|
187
290
|
return {
|
|
188
291
|
totalErrorCount,
|
|
@@ -190,7 +293,12 @@ class ESLintLinter {
|
|
|
190
293
|
totalFixableErrorCount,
|
|
191
294
|
totalFixableWarningCount,
|
|
192
295
|
totalWarningCount,
|
|
193
|
-
componentsResults
|
|
296
|
+
componentsResults,
|
|
297
|
+
totalComponentsWithErrorCount,
|
|
298
|
+
totalComponentsWithFatalErrorCount,
|
|
299
|
+
totalComponentsWithFixableErrorCount,
|
|
300
|
+
totalComponentsWithFixableWarningCount,
|
|
301
|
+
totalComponentsWithWarningCount
|
|
194
302
|
};
|
|
195
303
|
}
|
|
196
304
|
/**
|
|
@@ -216,4 +324,8 @@ class ESLintLinter {
|
|
|
216
324
|
|
|
217
325
|
exports.ESLintLinter = ESLintLinter;
|
|
218
326
|
|
|
327
|
+
function getCacheDir(rootDir) {
|
|
328
|
+
return _path().default.join(rootDir, 'node_modules', '.cache');
|
|
329
|
+
}
|
|
330
|
+
|
|
219
331
|
//# sourceMappingURL=eslint.linter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ESLintLinter","constructor","logger","options","ESLint","displayConfig","JSON","stringify","lint","context","longProcessLogger","createLongProcessLogger","components","length","resultsP","mapSeries","component","logProgress","id","toString","eslint","createEslint","config","filesP","filesystem","files","map","file","extensions","includes","extname","undefined","sourceCode","contents","lintResults","lintText","filePath","path","warnIgnored","fix","ESLintLib","outputFixes","Promise","all","results","compact","flatten","formatter","loadFormatter","output","format","totalErrorCount","totalFatalErrorCount","totalFixableErrorCount","totalFixableWarningCount","totalWarningCount","componentsResults","computeComponentResultsWithTotals","computeManyComponentsTotals","errors","result","errorCount","fatalErrorCount","fixableErrorCount","fixableWarningCount","warningCount","messages","raw","forEach","ESLintModule","version"],"sources":["eslint.linter.ts"],"sourcesContent":["import { 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 { 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 resultsP = mapSeries(context.components, async (component) => {\n longProcessLogger.logProgress(component.id.toString());\n const eslint = this.createEslint(this.options.config, this.ESLint);\n const filesP = component.filesystem.files.map(async (file) => {\n // The eslint api ignore extensions by default when using lintText, so we do it manually\n if (!this.options.extensions?.includes(file.extname)) return undefined;\n const sourceCode = file.contents.toString('utf8');\n const lintResults = await eslint.lintText(sourceCode, {\n filePath: file.path,\n warnIgnored: true,\n });\n\n if (eslint && this.options.config.fix && lintResults) {\n await ESLintLib.outputFixes(lintResults);\n }\n\n return lintResults;\n });\n\n const files = await Promise.all(filesP);\n\n const results: ESLintLib.LintResult[] = compact(flatten(files));\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 } = this.computeManyComponentsTotals(results);\n\n return {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n results,\n errors: [],\n };\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 componentsResults.forEach((result) => {\n totalErrorCount += result.totalErrorCount ?? 0;\n // @ts-ignore - missing from the @types/eslint lib\n totalFatalErrorCount += result.totalFatalErrorCount ?? 0;\n totalFixableErrorCount += result.totalFixableErrorCount ?? 0;\n totalFixableWarningCount += result.totalFixableWarningCount ?? 0;\n totalWarningCount += result.totalWarningCount ?? 0;\n });\n return {\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n componentsResults,\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,MAAMA,YAAN,CAAqC;EAC1CC,WAAW,CACDC,MADC,EAGDC,OAHC;EAKT;AACJ;AACA;EACYC,MARC,EAST;IAAA,KARQF,MAQR,GARQA,MAQR;IAAA,KANQC,OAMR,GANQA,OAMR;IAAA,KADQC,MACR,GADQA,MACR;IAAA,qDAEY,QAFZ;EAAE;;EAIJC,aAAa,GAAG;IACd,OAAOC,IAAI,CAACC,SAAL,CAAe,KAAKJ,OAApB,EAA6B,IAA7B,EAAmC,CAAnC,CAAP;EACD;;EAES,MAAJK,IAAI,CAACC,OAAD,EAA+C;IACvD,MAAMC,iBAAiB,GAAG,KAAKR,MAAL,CAAYS,uBAAZ,CAAoC,oBAApC,EAA0DF,OAAO,CAACG,UAAR,CAAmBC,MAA7E,CAA1B;IACA,MAAMC,QAAQ,GAAG,IAAAC,qBAAA,EAAUN,OAAO,CAACG,UAAlB,EAA8B,MAAOI,SAAP,IAAqB;MAClEN,iBAAiB,CAACO,WAAlB,CAA8BD,SAAS,CAACE,EAAV,CAAaC,QAAb,EAA9B;MACA,MAAMC,MAAM,GAAG,KAAKC,YAAL,CAAkB,KAAKlB,OAAL,CAAamB,MAA/B,EAAuC,KAAKlB,MAA5C,CAAf;MACA,MAAMmB,MAAM,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SON","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;IAA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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"}
|
|
@@ -19,6 +19,13 @@ export declare type ESLintOptions = {
|
|
|
19
19
|
* file types to lint.
|
|
20
20
|
*/
|
|
21
21
|
extensions?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* typescript config for eslint.
|
|
24
|
+
* If you pass this, bit will auto generate a temp config file in `node_modules/.cache` and pass it to eslint.
|
|
25
|
+
* 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.
|
|
26
|
+
* a `../../` will be added to the beginning of the path.
|
|
27
|
+
*/
|
|
28
|
+
tsConfig?: Record<string, any>;
|
|
22
29
|
};
|
|
23
30
|
export declare type EslintConfigTransformContext = {
|
|
24
31
|
fix: boolean;
|
|
@@ -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\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;;
|
|
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,UAAN,CAAiB;EACtBC,WAAW,CAASC,MAAT,EAAyB;IAAA,KAAhBA,MAAgB,GAAhBA,MAAgB;EAAE;EAEtC;AACF;AACA;AACA;AACA;;;EACEC,YAAY,CACVC,OADU,EAEVC,OAFU,EAGVC,YAAuC,GAAG,EAHhC,EAIVC,YAJU,EAKF;IACR,MAAMC,aAAa,GAAGC,UAAU,CAACJ,OAAD,EAAUD,OAAV,CAAhC;IACA,MAAMM,aAAa,GAAG,KAAIC,qCAAJ,EAAwBH,aAAxB,CAAtB;IACA,MAAMI,kBAAgD,GAAG;MAAEC,GAAG,EAAE,CAAC,CAACT,OAAO,CAACS;IAAjB,CAAzD;IACA,MAAMC,aAAa,GAAGC,0BAA0B,CAACL,aAAa,CAACM,KAAd,EAAD,EAAwBV,YAAxB,EAAsCM,kBAAtC,CAAhD;IAEA,OAAO,KAAIK,uBAAJ,EAAiB,KAAKf,MAAtB,EAA8BY,aAAa,CAACI,GAA5C,EAAiDX,YAAjD,CAAP;EACD;;EAMoB,aAARY,QAAQ,CAAC,CAACC,SAAD,CAAD,EAAiD;IACpE,MAAMlB,MAAM,GAAGkB,SAAS,CAACC,YAAV,CAAuBC,sBAAA,CAAaC,EAApC,CAAf;IACA,OAAO,IAAIvB,UAAJ,CAAeE,MAAf,CAAP;EACD;;AA7BqB;;;gCAAXF,U,aAsBMwB,kB;gCAtBNxB,U,kBAwBW,CAACyB,sBAAD,C;;AAQxBH,sBAAA,CAAaI,UAAb,CAAwB1B,UAAxB;AAEA;AACA;AACA;;;AACA,SAASS,UAAT,CAAoBJ,OAApB,EAA4CD,OAA5C,EAAmF;EACjF,MAAMuB,YAA+B,GAAG;IACtC;IACAC,cAAc,EAAEvB,OAAO,CAACwB,MAFc;IAGtCC,UAAU,EAAE1B,OAAO,CAAC2B,gBAHkB;IAItCC,WAAW,EAAE,KAJyB;IAKtCC,GAAG,EAAE5B,OAAO,CAAC6B,UALyB;IAMtCrB,GAAG,EAAE,CAAC,CAACT,OAAO,CAACS,GANuB;IAOtCsB,QAAQ,EAAE/B,OAAO,CAAC+B;EAPoB,CAAxC;EASA,OAAOC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBhC,OAAlB,EAA2B;IAAEwB,MAAM,EAAEF,YAAV;IAAwBG,UAAU,EAAE1B,OAAO,CAAC2B;EAA5C,CAA3B,CAAP;AACD;;AAEM,SAAShB,0BAAT,CACLc,MADK,EAELvB,YAAuC,GAAG,EAFrC,EAGLF,OAHK,EAIgB;EACrB,IAAI,CAACkC,KAAK,CAACC,OAAN,CAAcjC,YAAd,CAAL,EAAkC,OAAOuB,MAAP;EAClC,MAAMW,SAAS,GAAGlC,YAAY,CAACmC,MAAb,CAAoB,CAACC,GAAD,EAAMC,WAAN,KAAsB;IAC1D,OAAOA,WAAW,CAACD,GAAD,EAAMtC,OAAN,CAAlB;EACD,CAFiB,EAEfyB,MAFe,CAAlB;EAGA,OAAOW,SAAP;AACD"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/eslint",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.859",
|
|
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.859"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"eslint": "7.32.0",
|
|
13
|
+
"fs-extra": "10.0.0",
|
|
13
14
|
"lodash": "4.17.21",
|
|
15
|
+
"object-hash": "2.1.1",
|
|
14
16
|
"p-map-series": "2.1.0",
|
|
15
17
|
"@babel/runtime": "7.12.18",
|
|
16
18
|
"core-js": "^3.0.0",
|
|
17
19
|
"@teambit/harmony": "0.3.3",
|
|
18
|
-
"@teambit/linter": "0.0.
|
|
19
|
-
"@teambit/logger": "0.0.
|
|
20
|
-
"@teambit/cli": "0.0.
|
|
21
|
-
"@teambit/defender.eslint.config-mutator": "0.0.
|
|
20
|
+
"@teambit/linter": "0.0.859",
|
|
21
|
+
"@teambit/logger": "0.0.664",
|
|
22
|
+
"@teambit/cli": "0.0.571",
|
|
23
|
+
"@teambit/defender.eslint.config-mutator": "0.0.91"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
26
|
"@types/react": "^17.0.8",
|
|
25
27
|
"@types/eslint": "7.28.0",
|
|
28
|
+
"@types/fs-extra": "9.0.7",
|
|
26
29
|
"@types/lodash": "4.14.165",
|
|
30
|
+
"@types/object-hash": "1.3.4",
|
|
27
31
|
"@types/testing-library__jest-dom": "5.9.5",
|
|
28
32
|
"@types/jest": "^26.0.0",
|
|
29
33
|
"@types/react-dom": "^17.0.5",
|
|
@@ -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.859/dist/eslint.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.859/dist/eslint.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
Binary file
|