@teambit/linter 0.0.945 → 0.0.946
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/linter.service.d.ts +7 -2
- package/dist/linter.service.js +7 -0
- package/dist/linter.service.js.map +1 -1
- package/dist/{preview-1672284308356.js → preview-1672331186584.js} +2 -2
- package/linter.service.tsx +13 -1
- package/package-tar/teambit-linter-0.0.946.tgz +0 -0
- package/package.json +7 -7
- package/package-tar/teambit-linter-0.0.945.tgz +0 -0
package/dist/linter.service.d.ts
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';
|
2
|
+
import { EnvService, ExecutionContext, EnvDefinition, ServiceTransformationMap, EnvContext, Env } from '@teambit/envs';
|
3
3
|
import { Workspace } from '@teambit/workspace';
|
4
|
-
import { LintResults } from './linter';
|
4
|
+
import { Linter, LintResults } from './linter';
|
5
5
|
import { LinterOptions } from './linter-context';
|
6
6
|
import { LinterConfig } from './linter.main.runtime';
|
7
|
+
declare type LinterTransformationMap = ServiceTransformationMap & {
|
8
|
+
getLinter: () => Linter;
|
9
|
+
};
|
7
10
|
export declare class LinterService implements EnvService<LintResults> {
|
8
11
|
private linterConfig;
|
9
12
|
private workspace;
|
@@ -14,6 +17,7 @@ export declare class LinterService implements EnvService<LintResults> {
|
|
14
17
|
private mergeContext;
|
15
18
|
private getComponentsDirectory;
|
16
19
|
render(env: EnvDefinition): JSX.Element;
|
20
|
+
transform(env: Env, context: EnvContext): LinterTransformationMap | undefined;
|
17
21
|
getDescriptor(env: EnvDefinition): {
|
18
22
|
id: any;
|
19
23
|
icon: any;
|
@@ -22,3 +26,4 @@ export declare class LinterService implements EnvService<LintResults> {
|
|
22
26
|
displayName: any;
|
23
27
|
} | undefined;
|
24
28
|
}
|
29
|
+
export {};
|
package/dist/linter.service.js
CHANGED
@@ -95,6 +95,13 @@ class LinterService {
|
|
95
95
|
ignoreIllegals: true
|
96
96
|
})), /*#__PURE__*/_react().default.createElement(_ink().Newline, null));
|
97
97
|
}
|
98
|
+
transform(env, context) {
|
99
|
+
// Old env
|
100
|
+
if (!(env !== null && env !== void 0 && env.linter)) return undefined;
|
101
|
+
return {
|
102
|
+
getLinter: () => env.linter()(context)
|
103
|
+
};
|
104
|
+
}
|
98
105
|
getDescriptor(env) {
|
99
106
|
if (!env.env.getLinter) return undefined;
|
100
107
|
const mergedOpts = this.optionsWithDefaults({});
|
@@ -1 +1 @@
|
|
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"],"mappings":";;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;
|
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","transform","icon","displayConfig"],"sources":["linter.service.tsx"],"sourcesContent":["import React from 'react';\nimport { defaults } from 'lodash';\nimport { EnvService, ExecutionContext, EnvDefinition, ServiceTransformationMap, EnvContext, Env } 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\ntype LinterTransformationMap = ServiceTransformationMap & {\n getLinter: () => Linter;\n}\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 transform(env: Env, context: EnvContext): LinterTransformationMap | undefined {\n // Old env\n if (!env?.linter) return undefined;\n return {\n getLinter: () => env.linter()(context),\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"],"mappings":";;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AASO,MAAMA,aAAa,CAAoC;EAG5DC,WAAW,CAASC,YAA0B,EAAUC,SAAoB,EAAE;IAAA,KAA1DD,YAA0B,GAA1BA,YAA0B;IAAA,KAAUC,SAAoB,GAApBA,SAAoB;IAAA,8CAFrE,QAAQ;EAEgE;EAE/E,MAAMC,GAAG,CAACC,OAAyB,EAAEC,OAAsB,EAAwB;IACjF,MAAMC,UAAU,GAAG,IAAI,CAACC,mBAAmB,CAACF,OAAO,CAAC;IACpD,MAAMG,aAAa,GAAG,IAAI,CAACC,YAAY,CAACH,UAAU,EAAEF,OAAO,CAAC;IAC5D,MAAMM,MAAc,GAAGN,OAAO,CAACO,GAAG,CAACC,SAAS,CAACJ,aA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;MACjBL,MAAM,EAAE9B,MAAM,CAACoC,aAAa,GAAGpC,MAAM,CAACoC,aAAa,EAAE,GAAGb,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.946/dist/linter.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@0.0.946/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
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { defaults } from 'lodash';
|
3
|
-
import { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';
|
3
|
+
import { EnvService, ExecutionContext, EnvDefinition, ServiceTransformationMap, EnvContext, Env } from '@teambit/envs';
|
4
4
|
import { Text, Newline } from 'ink';
|
5
5
|
import { Workspace } from '@teambit/workspace';
|
6
6
|
import highlight from 'cli-highlight';
|
@@ -9,6 +9,10 @@ import { Linter, LintResults } from './linter';
|
|
9
9
|
import { LinterContext, LinterOptions } from './linter-context';
|
10
10
|
import { LinterConfig } from './linter.main.runtime';
|
11
11
|
|
12
|
+
type LinterTransformationMap = ServiceTransformationMap & {
|
13
|
+
getLinter: () => Linter;
|
14
|
+
}
|
15
|
+
|
12
16
|
export class LinterService implements EnvService<LintResults> {
|
13
17
|
name = 'linter';
|
14
18
|
|
@@ -72,6 +76,14 @@ export class LinterService implements EnvService<LintResults> {
|
|
72
76
|
);
|
73
77
|
}
|
74
78
|
|
79
|
+
transform(env: Env, context: EnvContext): LinterTransformationMap | undefined {
|
80
|
+
// Old env
|
81
|
+
if (!env?.linter) return undefined;
|
82
|
+
return {
|
83
|
+
getLinter: () => env.linter()(context),
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
75
87
|
getDescriptor(env: EnvDefinition) {
|
76
88
|
if (!env.env.getLinter) return undefined;
|
77
89
|
const mergedOpts = this.optionsWithDefaults({});
|
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.946",
|
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.946"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"chalk": "2.4.2",
|
@@ -18,11 +18,11 @@
|
|
18
18
|
"@babel/runtime": "7.20.0",
|
19
19
|
"@teambit/harmony": "0.4.6",
|
20
20
|
"@teambit/cli": "0.0.633",
|
21
|
-
"@teambit/component": "0.0.
|
22
|
-
"@teambit/envs": "0.0.
|
23
|
-
"@teambit/workspace": "0.0.
|
24
|
-
"@teambit/builder": "0.0.
|
25
|
-
"@teambit/isolator": "0.0.
|
21
|
+
"@teambit/component": "0.0.946",
|
22
|
+
"@teambit/envs": "0.0.946",
|
23
|
+
"@teambit/workspace": "0.0.946",
|
24
|
+
"@teambit/builder": "0.0.946",
|
25
|
+
"@teambit/isolator": "0.0.946",
|
26
26
|
"@teambit/logger": "0.0.726"
|
27
27
|
},
|
28
28
|
"devDependencies": {
|
Binary file
|