@teambit/linter 0.0.937 → 0.0.938
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/lint.task.d.ts +1 -0
- package/dist/lint.task.js +27 -1
- package/dist/lint.task.js.map +1 -1
- package/dist/linter-context.d.ts +5 -0
- package/dist/linter-context.js.map +1 -1
- package/dist/linter.main.runtime.js +1 -1
- package/dist/linter.main.runtime.js.map +1 -1
- package/dist/linter.service.d.ts +4 -2
- package/dist/linter.service.js +19 -4
- package/dist/linter.service.js.map +1 -1
- package/dist/{preview-1671506809302.js → preview-1671593083147.js} +2 -2
- package/linter.service.tsx +14 -2
- package/package-tar/teambit-linter-0.0.938.tgz +0 -0
- package/package.json +10 -9
- package/package-tar/teambit-linter-0.0.937.tgz +0 -0
package/dist/lint.task.d.ts
CHANGED
package/dist/lint.task.js
CHANGED
@@ -13,6 +13,20 @@ function _defineProperty2() {
|
|
13
13
|
};
|
14
14
|
return data;
|
15
15
|
}
|
16
|
+
function _path() {
|
17
|
+
const data = _interopRequireDefault(require("path"));
|
18
|
+
_path = function () {
|
19
|
+
return data;
|
20
|
+
};
|
21
|
+
return data;
|
22
|
+
}
|
23
|
+
function _component() {
|
24
|
+
const data = require("@teambit/component");
|
25
|
+
_component = function () {
|
26
|
+
return data;
|
27
|
+
};
|
28
|
+
return data;
|
29
|
+
}
|
16
30
|
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; }
|
17
31
|
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; }
|
18
32
|
class LintTask {
|
@@ -22,9 +36,13 @@ class LintTask {
|
|
22
36
|
}
|
23
37
|
async execute(context) {
|
24
38
|
const linter = context.env.getLinter();
|
39
|
+
const rootDir = context.capsuleNetwork.capsulesRootDir;
|
40
|
+
const componentsDirMap = this.getComponentsDirectory(rootDir, context.components, context.capsuleNetwork.graphCapsules);
|
41
|
+
|
25
42
|
// @ts-ignore TODO: fix this
|
26
43
|
const linterContext = _objectSpread({
|
27
|
-
rootDir
|
44
|
+
rootDir,
|
45
|
+
componentsDirMap
|
28
46
|
}, context);
|
29
47
|
const results = await linter.lint(linterContext);
|
30
48
|
const componentsResults = results.results.map(lintResult => {
|
@@ -41,6 +59,14 @@ class LintTask {
|
|
41
59
|
componentsResults
|
42
60
|
};
|
43
61
|
}
|
62
|
+
getComponentsDirectory(capsuleRootDir, components, capsuleList) {
|
63
|
+
return _component().ComponentMap.as(components, component => {
|
64
|
+
var _capsuleList$getCapsu;
|
65
|
+
const fullPath = ((_capsuleList$getCapsu = capsuleList.getCapsule(component.id)) === null || _capsuleList$getCapsu === void 0 ? void 0 : _capsuleList$getCapsu.path) || '';
|
66
|
+
const relativePath = _path().default.relative(capsuleRootDir, fullPath);
|
67
|
+
return relativePath;
|
68
|
+
});
|
69
|
+
}
|
44
70
|
}
|
45
71
|
exports.LintTask = LintTask;
|
46
72
|
|
package/dist/lint.task.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["LintTask","constructor","aspectId","name","execute","context","linter","env","getLinter","
|
1
|
+
{"version":3,"names":["LintTask","constructor","aspectId","name","execute","context","linter","env","getLinter","rootDir","capsuleNetwork","capsulesRootDir","componentsDirMap","getComponentsDirectory","components","graphCapsules","linterContext","results","lint","componentsResults","map","lintResult","component","metadata","output","errors","capsuleRootDir","capsuleList","ComponentMap","as","fullPath","getCapsule","id","path","relativePath","relative"],"sources":["lint.task.ts"],"sourcesContent":["import path from 'path';\nimport { BuildTask, BuiltTaskResult, BuildContext, ComponentResult } from '@teambit/builder';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { CapsuleList } from '@teambit/isolator';\nimport { Linter } from './linter';\nimport { LinterContext } from './linter-context';\n\nexport class LintTask implements BuildTask {\n constructor(readonly aspectId: string, readonly name = 'lint') {}\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const linter: Linter = context.env.getLinter();\n const rootDir = context.capsuleNetwork.capsulesRootDir;\n const componentsDirMap = this.getComponentsDirectory(\n rootDir,\n context.components,\n context.capsuleNetwork.graphCapsules\n );\n\n // @ts-ignore TODO: fix this\n const linterContext: LinterContext = {\n rootDir,\n componentsDirMap,\n ...context,\n };\n const results = await linter.lint(linterContext);\n const componentsResults = results.results.map((lintResult): ComponentResult => {\n return {\n component: lintResult.component,\n metadata: {\n output: lintResult.output,\n results: lintResult.results,\n },\n errors: [],\n };\n });\n\n return {\n componentsResults,\n };\n }\n\n private getComponentsDirectory(\n capsuleRootDir: string,\n components: Component[],\n capsuleList: CapsuleList\n ): ComponentMap<string> {\n return ComponentMap.as<string>(components, (component) => {\n const fullPath = capsuleList.getCapsule(component.id)?.path || '';\n const relativePath = path.relative(capsuleRootDir, fullPath);\n return relativePath;\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA6D;AAAA;AAKtD,MAAMA,QAAQ,CAAsB;EACzCC,WAAW,CAAUC,QAAgB,EAAWC,IAAI,GAAG,MAAM,EAAE;IAAA,KAA1CD,QAAgB,GAAhBA,QAAgB;IAAA,KAAWC,IAAI,GAAJA,IAAI;EAAY;EAEhE,MAAMC,OAAO,CAACC,OAAqB,EAA4B;IAC7D,MAAMC,MAAc,GAAGD,OAAO,CAACE,GAAG,CAACC,SAAS,EAAE;IAC9C,MAAMC,OAAO,GAAGJ,OAAO,CAACK,cAAc,CAACC,eAAe;IACtD,MAAMC,gBAAgB,GAAG,IAAI,CAACC,sBAAsB,CAClDJ,OAAO,EACPJ,OAAO,CAACS,UAAU,EAClBT,OAAO,CAACK,cAAc,CAACK,aAAa,CACrC;;IAED;IACA,MAAMC,aAA4B;MAChCP,OAAO;MACPG;IAAgB,GACbP,OAAO,CACX;IACD,MAAMY,OAAO,GAAG,MAAMX,MAAM,CAACY,IAAI,CAACF,aAAa,CAAC;IAChD,MAAMG,iBAAiB,GAAGF,OAAO,CAACA,OAAO,CAACG,GAAG,CAAEC,UAAU,IAAsB;MAC7E,OAAO;QACLC,SAAS,EAAED,UAAU,CAACC,SAAS;QAC/BC,QAAQ,EAAE;UACRC,MAAM,EAAEH,UAAU,CAACG,MAAM;UACzBP,OAAO,EAAEI,UAAU,CAACJ;QACtB,CAAC;QACDQ,MAAM,EAAE;MACV,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;MACLN;IACF,CAAC;EACH;EAEQN,sBAAsB,CAC5Ba,cAAsB,EACtBZ,UAAuB,EACvBa,WAAwB,EACF;IACtB,OAAOC,yBAAY,CAACC,EAAE,CAASf,UAAU,EAAGQ,SAAS,IAAK;MAAA;MACxD,MAAMQ,QAAQ,GAAG,0BAAAH,WAAW,CAACI,UAAU,CAACT,SAAS,CAACU,EAAE,CAAC,0DAApC,sBAAsCC,IAAI,KAAI,EAAE;MACjE,MAAMC,YAAY,GAAGD,eAAI,CAACE,QAAQ,CAACT,cAAc,EAAEI,QAAQ,CAAC;MAC5D,OAAOI,YAAY;IACrB,CAAC,CAAC;EACJ;AACF;AAAC"}
|
package/dist/linter-context.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { ComponentMap } from '@teambit/component';
|
1
2
|
import { ExecutionContext } from '@teambit/envs';
|
2
3
|
export declare type FixType = 'problem' | 'suggestion' | 'layout';
|
3
4
|
export declare type FixTypes = Array<FixType>;
|
@@ -22,4 +23,8 @@ export interface LinterContext extends ExecutionContext, LinterOptions {
|
|
22
23
|
* Usually it's the workspace root dir or the capsule root dir
|
23
24
|
*/
|
24
25
|
rootDir?: string;
|
26
|
+
/**
|
27
|
+
* Component map with the path to the component in the fs
|
28
|
+
*/
|
29
|
+
componentsDirMap: ComponentMap<string>;
|
25
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["linter-context.ts"],"sourcesContent":["import { ExecutionContext } from '@teambit/envs';\n\nexport type FixType = 'problem' | 'suggestion' | 'layout';\nexport type FixTypes = Array<FixType>;\n\nexport interface LinterOptions {\n /**\n * extensions formats to lint. (e.g. .ts, .tsx, etc.)\n */\n extensionFormats?: string[];\n\n /**\n * automatically fix problems\n */\n fix?: boolean;\n\n /**\n * specify the types of fixes to apply (problem, suggestion, layout)\n */\n fixTypes?: FixTypes;\n}\nexport interface LinterContext extends ExecutionContext, LinterOptions {\n quiet?: boolean;\n /**\n * Root dir that contains all the components in the fs that are about to be linted\n * Usually it's the workspace root dir or the capsule root dir\n */\n rootDir?: string;\n}\n"],"mappings":""}
|
1
|
+
{"version":3,"names":[],"sources":["linter-context.ts"],"sourcesContent":["import { ComponentMap } from '@teambit/component';\nimport { ExecutionContext } from '@teambit/envs';\n\nexport type FixType = 'problem' | 'suggestion' | 'layout';\nexport type FixTypes = Array<FixType>;\n\nexport interface LinterOptions {\n /**\n * extensions formats to lint. (e.g. .ts, .tsx, etc.)\n */\n extensionFormats?: string[];\n\n /**\n * automatically fix problems\n */\n fix?: boolean;\n\n /**\n * specify the types of fixes to apply (problem, suggestion, layout)\n */\n fixTypes?: FixTypes;\n}\nexport interface LinterContext extends ExecutionContext, LinterOptions {\n quiet?: boolean;\n /**\n * Root dir that contains all the components in the fs that are about to be linted\n * Usually it's the workspace root dir or the capsule root dir\n */\n rootDir?: string;\n\n /**\n * Component map with the path to the component in the fs\n */\n componentsDirMap: ComponentMap<string>\n}\n"],"mappings":""}
|
@@ -102,7 +102,7 @@ class LinterMain {
|
|
102
102
|
static async provider([envs, cli, component, loggerAspect, workspace], config) {
|
103
103
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
104
104
|
const logger = loggerAspect.createLogger(_linter().LinterAspect.id);
|
105
|
-
const linterService = new (_linter2().LinterService)(config, workspace
|
105
|
+
const linterService = new (_linter2().LinterService)(config, workspace);
|
106
106
|
const linterAspect = new LinterMain(envs, linterService);
|
107
107
|
envs.registerService(linterService);
|
108
108
|
cli.register(new (_lint2().LintCmd)(linterAspect, component.getHost(), workspace));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["LinterMain","constructor","envs","linterService","lint","components","opts","envsRuntime","createEnvironment","lintResults","run","createTask","name","LintTask","LinterAspect","id","provider","cli","component","loggerAspect","workspace","config","logger","createLogger","LinterService","
|
1
|
+
{"version":3,"names":["LinterMain","constructor","envs","linterService","lint","components","opts","envsRuntime","createEnvironment","lintResults","run","createTask","name","LintTask","LinterAspect","id","provider","cli","component","loggerAspect","workspace","config","logger","createLogger","LinterService","linterAspect","registerService","register","LintCmd","getHost","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","LoggerAspect","WorkspaceAspect","extensionFormats","fixTypes","addRuntime"],"sources":["linter.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain } from '@teambit/component';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { LinterAspect } from './linter.aspect';\nimport { LinterService } from './linter.service';\nimport { LintTask } from './lint.task';\nimport { LintCmd } from './lint.cmd';\nimport { FixTypes, LinterOptions } from './linter-context';\n\nexport type LinterConfig = {\n /**\n * extension formats to lint.\n */\n extensionFormats: string[];\n fixTypes?: FixTypes;\n};\n\nexport class LinterMain {\n static runtime = MainRuntime;\n\n constructor(private envs: EnvsMain, private linterService: LinterService) {}\n\n /**\n * lint an array of components.\n */\n async lint(components: Component[], opts: LinterOptions) {\n const envsRuntime = await this.envs.createEnvironment(components);\n const lintResults = envsRuntime.run(this.linterService, opts);\n return lintResults;\n }\n\n /**\n * create a lint task for build pipelines.\n * @param name name of the task.\n */\n createTask(name?: string): LintTask {\n return new LintTask(LinterAspect.id, name);\n }\n\n static dependencies = [EnvsAspect, CLIAspect, ComponentAspect, LoggerAspect, WorkspaceAspect];\n\n static defaultConfig: LinterConfig = {\n extensionFormats: ['.ts', '.tsx', '.js', '.jsx', '.mjs'],\n fixTypes: ['layout', 'problem', 'suggestion'],\n };\n\n static async provider(\n [envs, cli, component, loggerAspect, workspace]: [EnvsMain, CLIMain, ComponentMain, LoggerMain, Workspace],\n config: LinterConfig\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const logger = loggerAspect.createLogger(LinterAspect.id);\n const linterService = new LinterService(config, workspace);\n const linterAspect = new LinterMain(envs, linterService);\n envs.registerService(linterService);\n cli.register(new LintCmd(linterAspect, component.getHost(), workspace));\n\n return linterAspect;\n }\n}\n\nLinterAspect.addRuntime(LinterMain);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;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;AACA;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;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAWO,MAAMA,UAAU,CAAC;EAGtBC,WAAW,CAASC,IAAc,EAAUC,aAA4B,EAAE;IAAA,KAAtDD,IAAc,GAAdA,IAAc;IAAA,KAAUC,aA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C;EACxDC,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY;AAC9C,CAAC;AAiBHvB,sBAAY,CAACwB,UAAU,CAACtC,UAAU,CAAC"}
|
package/dist/linter.service.d.ts
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';
|
3
|
+
import { Workspace } from '@teambit/workspace';
|
3
4
|
import { LintResults } from './linter';
|
4
5
|
import { LinterOptions } from './linter-context';
|
5
6
|
import { LinterConfig } from './linter.main.runtime';
|
6
7
|
export declare class LinterService implements EnvService<LintResults> {
|
7
8
|
private linterConfig;
|
8
|
-
private
|
9
|
+
private workspace;
|
9
10
|
name: string;
|
10
|
-
constructor(linterConfig: LinterConfig,
|
11
|
+
constructor(linterConfig: LinterConfig, workspace: Workspace);
|
11
12
|
run(context: ExecutionContext, options: LinterOptions): Promise<LintResults>;
|
12
13
|
private optionsWithDefaults;
|
13
14
|
private mergeContext;
|
15
|
+
private getComponentsDirectory;
|
14
16
|
render(env: EnvDefinition): JSX.Element;
|
15
17
|
getDescriptor(env: EnvDefinition): {
|
16
18
|
id: any;
|
package/dist/linter.service.js
CHANGED
@@ -41,10 +41,17 @@ function _cliHighlight() {
|
|
41
41
|
};
|
42
42
|
return data;
|
43
43
|
}
|
44
|
+
function _component() {
|
45
|
+
const data = require("@teambit/component");
|
46
|
+
_component = function () {
|
47
|
+
return data;
|
48
|
+
};
|
49
|
+
return data;
|
50
|
+
}
|
44
51
|
class LinterService {
|
45
|
-
constructor(linterConfig,
|
52
|
+
constructor(linterConfig, workspace) {
|
46
53
|
this.linterConfig = linterConfig;
|
47
|
-
this.
|
54
|
+
this.workspace = workspace;
|
48
55
|
(0, _defineProperty2().default)(this, "name", 'linter');
|
49
56
|
}
|
50
57
|
async run(context, options) {
|
@@ -58,15 +65,23 @@ class LinterService {
|
|
58
65
|
return (0, _lodash().defaults)(options, this.linterConfig);
|
59
66
|
}
|
60
67
|
mergeContext(options, context) {
|
68
|
+
var _this$workspace;
|
69
|
+
const componentsDirMap = context !== null && context !== void 0 && context.components ? this.getComponentsDirectory(context.components) : _component().ComponentMap.create([]);
|
61
70
|
const linterContext = Object.assign({}, {
|
62
|
-
rootDir: this.
|
71
|
+
rootDir: (_this$workspace = this.workspace) === null || _this$workspace === void 0 ? void 0 : _this$workspace.path,
|
63
72
|
quiet: false,
|
64
73
|
extensionFormats: options.extensionFormats,
|
65
74
|
fixTypes: options.fixTypes,
|
66
|
-
fix: options.fix
|
75
|
+
fix: options.fix,
|
76
|
+
componentsDirMap
|
67
77
|
}, context);
|
68
78
|
return linterContext;
|
69
79
|
}
|
80
|
+
getComponentsDirectory(components) {
|
81
|
+
return _component().ComponentMap.as(components, component => this.workspace.componentDir(component.id, undefined, {
|
82
|
+
relative: true
|
83
|
+
}));
|
84
|
+
}
|
70
85
|
render(env) {
|
71
86
|
const descriptor = this.getDescriptor(env);
|
72
87
|
return /*#__PURE__*/_react().default.createElement(_ink().Text, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["LinterService","constructor","linterConfig","
|
1
|
+
{"version":3,"names":["LinterService","constructor","linterConfig","workspace","run","context","options","mergedOpts","optionsWithDefaults","linterContext","mergeContext","linter","env","getLinter","results","lint","defaults","componentsDirMap","components","getComponentsDirectory","ComponentMap","create","Object","assign","rootDir","path","quiet","extensionFormats","fixTypes","fix","as","component","componentDir","id","undefined","relative","render","descriptor","getDescriptor","displayName","version","config","highlight","language","ignoreIllegals","icon","displayConfig"],"sources":["linter.service.tsx"],"sourcesContent":["import React from 'react';\nimport { defaults } from 'lodash';\nimport { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';\nimport { Text, Newline } from 'ink';\nimport { Workspace } from '@teambit/workspace';\nimport highlight from 'cli-highlight';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { Linter, LintResults } from './linter';\nimport { LinterContext, LinterOptions } from './linter-context';\nimport { LinterConfig } from './linter.main.runtime';\n\nexport class LinterService implements EnvService<LintResults> {\n name = 'linter';\n\n constructor(private linterConfig: LinterConfig, private workspace: Workspace) {}\n\n async run(context: ExecutionContext, options: LinterOptions): Promise<LintResults> {\n const mergedOpts = this.optionsWithDefaults(options);\n const linterContext = this.mergeContext(mergedOpts, context);\n const linter: Linter = context.env.getLinter(linterContext);\n\n const results = await linter.lint(linterContext);\n return results;\n }\n\n private optionsWithDefaults(options: LinterOptions): LinterOptions {\n return defaults(options, this.linterConfig);\n }\n\n private mergeContext(options: LinterOptions, context?: ExecutionContext): LinterContext {\n const componentsDirMap = context?.components\n ? this.getComponentsDirectory(context.components)\n : ComponentMap.create<string>([]);\n const linterContext: LinterContext = Object.assign(\n {},\n {\n rootDir: this.workspace?.path,\n quiet: false,\n extensionFormats: options.extensionFormats,\n fixTypes: options.fixTypes,\n fix: options.fix,\n componentsDirMap,\n },\n context\n );\n return linterContext;\n }\n\n private getComponentsDirectory(components: Component[]): ComponentMap<string> {\n return ComponentMap.as<string>(components, (component) =>\n this.workspace.componentDir(component.id, undefined, { relative: true })\n );\n }\n\n render(env: EnvDefinition) {\n const descriptor = this.getDescriptor(env);\n\n return (\n <Text key={descriptor?.id}>\n <Text color=\"cyan\">configured linter: </Text>\n <Text>\n {descriptor?.id} ({descriptor?.displayName} @ {descriptor?.version})\n </Text>\n <Newline />\n <Text color=\"cyan\">linter config:</Text>\n <Newline />\n <Text>\n {descriptor?.config && highlight(descriptor?.config, { language: 'javascript', ignoreIllegals: true })}\n </Text>\n <Newline />\n </Text>\n );\n }\n\n getDescriptor(env: EnvDefinition) {\n if (!env.env.getLinter) return undefined;\n const mergedOpts = this.optionsWithDefaults({});\n const linterContext = this.mergeContext(mergedOpts);\n const linter = env.env.getLinter(linterContext);\n\n return {\n id: linter.id,\n icon: linter.icon,\n config: linter.displayConfig ? linter.displayConfig() : undefined,\n version: linter.version ? linter.version() : '?',\n displayName: linter.displayName ? linter.displayName : '?',\n };\n }\n}\n"],"m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,+BAAC,cAAO,OAAG,CACN;EAEX;EAEAN,aAAa,CAAC1B,GAAkB,EAAE;IAChC,IAAI,CAACA,GAAG,CAACA,GAAG,CAACC,SAAS,EAAE,OAAOqB,SAAS;IACxC,MAAM3B,UAAU,GAAG,IAAI,CAACC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAC/C,MAAMC,aAAa,GAAG,IAAI,CAACC,YAAY,CAACH,UAAU,CAAC;IACnD,MAAMI,MAAM,GAAGC,GAAG,CAACA,GAAG,CAACC,SAAS,CAACJ,aAAa,CAAC;IAE/C,OAAO;MACLwB,EAAE,EAAEtB,MAAM,CAACsB,EAAE;MACbY,IAAI,EAAElC,MAAM,CAACkC,IAAI;MACjBJ,MAAM,EAAE9B,MAAM,CAACmC,aAAa,GAAGnC,MAAM,CAACmC,aAAa,EAAE,GAAGZ,SAAS;MACjEM,OAAO,EAAE7B,MAAM,CAAC6B,OAAO,GAAG7B,MAAM,CAAC6B,OAAO,EAAE,GAAG,GAAG;MAChDD,WAAW,EAAE5B,MAAM,CAAC4B,WAAW,GAAG5B,MAAM,CAAC4B,WAAW,GAAG;IACzD,CAAC;EACH;AACF;AAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@0.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@0.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@0.0.938/dist/linter.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@0.0.938/dist/linter.docs.mdx';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|
package/linter.service.tsx
CHANGED
@@ -2,7 +2,9 @@ import React from 'react';
|
|
2
2
|
import { defaults } from 'lodash';
|
3
3
|
import { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';
|
4
4
|
import { Text, Newline } from 'ink';
|
5
|
+
import { Workspace } from '@teambit/workspace';
|
5
6
|
import highlight from 'cli-highlight';
|
7
|
+
import { Component, ComponentMap } from '@teambit/component';
|
6
8
|
import { Linter, LintResults } from './linter';
|
7
9
|
import { LinterContext, LinterOptions } from './linter-context';
|
8
10
|
import { LinterConfig } from './linter.main.runtime';
|
@@ -10,7 +12,7 @@ import { LinterConfig } from './linter.main.runtime';
|
|
10
12
|
export class LinterService implements EnvService<LintResults> {
|
11
13
|
name = 'linter';
|
12
14
|
|
13
|
-
constructor(private linterConfig: LinterConfig, private
|
15
|
+
constructor(private linterConfig: LinterConfig, private workspace: Workspace) {}
|
14
16
|
|
15
17
|
async run(context: ExecutionContext, options: LinterOptions): Promise<LintResults> {
|
16
18
|
const mergedOpts = this.optionsWithDefaults(options);
|
@@ -26,20 +28,30 @@ export class LinterService implements EnvService<LintResults> {
|
|
26
28
|
}
|
27
29
|
|
28
30
|
private mergeContext(options: LinterOptions, context?: ExecutionContext): LinterContext {
|
31
|
+
const componentsDirMap = context?.components
|
32
|
+
? this.getComponentsDirectory(context.components)
|
33
|
+
: ComponentMap.create<string>([]);
|
29
34
|
const linterContext: LinterContext = Object.assign(
|
30
35
|
{},
|
31
36
|
{
|
32
|
-
rootDir: this.
|
37
|
+
rootDir: this.workspace?.path,
|
33
38
|
quiet: false,
|
34
39
|
extensionFormats: options.extensionFormats,
|
35
40
|
fixTypes: options.fixTypes,
|
36
41
|
fix: options.fix,
|
42
|
+
componentsDirMap,
|
37
43
|
},
|
38
44
|
context
|
39
45
|
);
|
40
46
|
return linterContext;
|
41
47
|
}
|
42
48
|
|
49
|
+
private getComponentsDirectory(components: Component[]): ComponentMap<string> {
|
50
|
+
return ComponentMap.as<string>(components, (component) =>
|
51
|
+
this.workspace.componentDir(component.id, undefined, { relative: true })
|
52
|
+
);
|
53
|
+
}
|
54
|
+
|
43
55
|
render(env: EnvDefinition) {
|
44
56
|
const descriptor = this.getDescriptor(env);
|
45
57
|
|
Binary file
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/linter",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.938",
|
4
4
|
"homepage": "https://bit.dev/teambit/defender/linter",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.defender",
|
8
8
|
"name": "linter",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.938"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"chalk": "2.4.2",
|
@@ -17,12 +17,13 @@
|
|
17
17
|
"core-js": "^3.0.0",
|
18
18
|
"@babel/runtime": "7.20.0",
|
19
19
|
"@teambit/harmony": "0.4.6",
|
20
|
-
"@teambit/cli": "0.0.
|
21
|
-
"@teambit/component": "0.0.
|
22
|
-
"@teambit/envs": "0.0.
|
23
|
-
"@teambit/workspace": "0.0.
|
24
|
-
"@teambit/builder": "0.0.
|
25
|
-
"@teambit/
|
20
|
+
"@teambit/cli": "0.0.629",
|
21
|
+
"@teambit/component": "0.0.938",
|
22
|
+
"@teambit/envs": "0.0.938",
|
23
|
+
"@teambit/workspace": "0.0.938",
|
24
|
+
"@teambit/builder": "0.0.938",
|
25
|
+
"@teambit/isolator": "0.0.938",
|
26
|
+
"@teambit/logger": "0.0.722"
|
26
27
|
},
|
27
28
|
"devDependencies": {
|
28
29
|
"@types/lodash": "4.14.165",
|
@@ -35,7 +36,7 @@
|
|
35
36
|
"@teambit/defender.content.linter-overview": "1.95.0"
|
36
37
|
},
|
37
38
|
"peerDependencies": {
|
38
|
-
"@teambit/legacy": "1.0.
|
39
|
+
"@teambit/legacy": "1.0.410",
|
39
40
|
"react": "^16.8.0 || ^17.0.0",
|
40
41
|
"react-dom": "^16.8.0 || ^17.0.0"
|
41
42
|
},
|
Binary file
|