@teambit/linter 1.0.106 → 1.0.108
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.cmd.d.ts +5 -5
- package/dist/lint.cmd.js +2 -3
- package/dist/lint.cmd.js.map +1 -1
- package/dist/lint.task.js +1 -2
- package/dist/lint.task.js.map +1 -1
- package/dist/linter-context.d.ts +2 -2
- package/dist/linter.composition.d.ts +2 -2
- package/dist/linter.d.ts +4 -4
- package/dist/linter.main.runtime.d.ts +1 -1
- package/dist/linter.service.d.ts +4 -4
- package/dist/linter.service.js +6 -7
- package/dist/linter.service.js.map +1 -1
- package/dist/{preview-1703505948637.js → preview-1703647408454.js} +2 -2
- package/index.ts +9 -0
- package/lint.cmd.ts +217 -0
- package/lint.task.ts +54 -0
- package/linter-context.ts +35 -0
- package/linter-env-type.ts +9 -0
- package/linter.aspect.ts +5 -0
- package/linter.graphql.ts +8 -0
- package/linter.main.runtime.ts +69 -0
- package/linter.ts +156 -0
- package/package.json +19 -26
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
package/dist/lint.cmd.d.ts
CHANGED
@@ -4,7 +4,7 @@ import { ComponentFactory, ComponentID } from '@teambit/component';
|
|
4
4
|
import { Workspace } from '@teambit/workspace';
|
5
5
|
import { LinterMain } from './linter.main.runtime';
|
6
6
|
import { ComponentLintResult, LintResults } from './linter';
|
7
|
-
export
|
7
|
+
export type LintCmdOptions = {
|
8
8
|
changed?: boolean;
|
9
9
|
fix?: boolean;
|
10
10
|
fixType?: string;
|
@@ -13,21 +13,21 @@ export declare type LintCmdOptions = {
|
|
13
13
|
/**
|
14
14
|
* A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component
|
15
15
|
*/
|
16
|
-
export
|
16
|
+
export type JsonComponentLintResult = Omit<ComponentLintResult, 'component'> & {
|
17
17
|
componentId: ComponentID;
|
18
18
|
};
|
19
|
-
export
|
19
|
+
export type JsonLintDataResults = Omit<LintResults, 'results'> & {
|
20
20
|
results: JsonComponentLintResult[];
|
21
21
|
};
|
22
22
|
/**
|
23
23
|
* A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component
|
24
24
|
*/
|
25
|
-
export
|
25
|
+
export type JsonLintResultsData = {
|
26
26
|
duration: TimerResponse;
|
27
27
|
lintResults: JsonLintDataResults;
|
28
28
|
componentsIdsToLint: string[];
|
29
29
|
};
|
30
|
-
export
|
30
|
+
export type JsonLintResults = {
|
31
31
|
code: number;
|
32
32
|
data: JsonLintResultsData;
|
33
33
|
};
|
package/dist/lint.cmd.js
CHANGED
@@ -158,8 +158,7 @@ function toJsonLintResults(results) {
|
|
158
158
|
let totalComponentsWithFixableWarningCount = 0;
|
159
159
|
let totalComponentsWithWarningCount = 0;
|
160
160
|
const newResults = results.results.map(res => {
|
161
|
-
|
162
|
-
const resultsWithoutComponent = (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.results.map(result => {
|
161
|
+
const resultsWithoutComponent = res.data?.results.map(result => {
|
163
162
|
return Object.assign({}, {
|
164
163
|
componentId: result.component.id
|
165
164
|
}, (0, _lodash().omit)(result, ['component']));
|
@@ -200,7 +199,7 @@ function toJsonLintResults(results) {
|
|
200
199
|
totalComponentsWithFixableErrorCount,
|
201
200
|
totalComponentsWithFixableWarningCount,
|
202
201
|
totalComponentsWithWarningCount,
|
203
|
-
errors: results
|
202
|
+
errors: results?.errors
|
204
203
|
};
|
205
204
|
}
|
206
205
|
|
package/dist/lint.cmd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_timer","data","require","_chalk","_interopRequireDefault","_lodash","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","LintCmd","constructor","linter","componentHost","workspace","report","components","linterOptions","code","json","lintResults","componentsIdsToLint","title","chalk","bold","cyan","length","toString","name","componentsOutputs","results","map","lintRes","compTitle","componentId","ignoreVersion","compOutput","output","join","summary","getSummarySection","duration","seconds","summaryTitle","totalFieldsMap","itemsDataField","componentsDataField","label","summaryTotals","item","renderTotalLine","filter","Boolean","componentsCount","itemsCount","fieldLabel","undefined","green","timer","Timer","create","start","componentsIds","getIdsToLint","changed","componentsToLint","getMany","opts","fix","fixTypes","fixType","split","linterResults","lint","jsonLinterResults","toJsonLintResults","timerResponse","stop","totalErrorCount","totalFatalErrorCount","comp","id","resolveMultipleComponentIds","getNewAndModifiedIds","listIds","exports","totalFixableErrorCount","totalFixableWarningCount","totalWarningCount","totalComponentsWithErrorCount","totalComponentsWithFatalErrorCount","totalComponentsWithFixableErrorCount","totalComponentsWithFixableWarningCount","totalComponentsWithWarningCount","newResults","res","_res$data","resultsWithoutComponent","result","assign","component","omit","compact","flatten","errors"],"sources":["lint.cmd.ts"],"sourcesContent":["import { TimerResponse, Timer } from '@teambit/legacy/dist/toolbox/timer';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentFactory, ComponentID } from '@teambit/component';\nimport chalk from 'chalk';\nimport { EnvsExecutionResult } from '@teambit/envs';\nimport { Workspace } from '@teambit/workspace';\nimport { compact, flatten, omit } from 'lodash';\nimport { LinterMain } from './linter.main.runtime';\nimport { ComponentLintResult, LintResults } from './linter';\nimport { FixTypes, LinterOptions } from './linter-context';\n\nexport type LintCmdOptions = {\n changed?: boolean;\n fix?: boolean;\n fixType?: string;\n json?: boolean;\n};\n\n/**\n * A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component\n */\nexport type JsonComponentLintResult = Omit<ComponentLintResult, 'component'> & {\n componentId: ComponentID;\n};\n\nexport type JsonLintDataResults = Omit<LintResults, 'results'> & { results: JsonComponentLintResult[] };\n/**\n * A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component\n */\nexport type JsonLintResultsData = {\n duration: TimerResponse;\n lintResults: JsonLintDataResults;\n componentsIdsToLint: string[];\n};\n\nexport type JsonLintResults = {\n code: number;\n data: JsonLintResultsData;\n};\n\nexport class LintCmd implements Command {\n name = 'lint [component...]';\n description = 'lint components in the development workspace';\n helpUrl = 'reference/linting/linter-overview';\n group = 'development';\n options = [\n ['c', 'changed', 'lint only new and modified components'],\n ['f', 'fix', 'automatically fix problems'],\n ['', 'fix-type <fixType>', 'specify the types of fixes to apply (problem, suggestion, layout)'],\n ['j', 'json', 'return the lint results in json format'],\n ] as CommandOptions;\n\n constructor(private linter: LinterMain, private componentHost: ComponentFactory, private workspace: Workspace) {}\n\n async report([components = []]: [string[]], linterOptions: LintCmdOptions) {\n const { code, data } = await this.json([components], linterOptions);\n const { lintResults, componentsIdsToLint } = data;\n const title = chalk.bold(\n `linting total of ${chalk.cyan(componentsIdsToLint.length.toString())} component(s) in workspace '${chalk.cyan(\n this.componentHost.name\n )}'`\n );\n\n const componentsOutputs = lintResults.results\n .map((lintRes) => {\n const compTitle = chalk.bold.cyan(lintRes.componentId.toString({ ignoreVersion: true }));\n const compOutput = lintRes.output;\n return `${compTitle}\\n${compOutput}`;\n })\n .join('\\n');\n\n const summary = this.getSummarySection(data);\n return { code, data: `${title}\\n\\n${componentsOutputs}\\n\\n${summary}` };\n }\n\n private getSummarySection(data: JsonLintResultsData) {\n const { duration, lintResults, componentsIdsToLint } = data;\n const { seconds } = duration;\n const summaryTitle = `linted ${chalk.cyan(componentsIdsToLint.length.toString())} components in ${chalk.cyan(\n seconds.toString()\n )} seconds`;\n\n const totalFieldsMap = [\n { itemsDataField: 'totalErrorCount', componentsDataField: 'totalComponentsWithErrorCount', label: 'Errors' },\n {\n itemsDataField: 'totalFatalErrorCount',\n componentsDataField: 'totalComponentsWithFatalErrorCount',\n label: 'FatalErrors',\n },\n {\n itemsDataField: 'totalFixableErrorCount',\n componentsDataField: 'totalComponentsWithFixableErrorCount',\n label: 'FixableErrors',\n },\n {\n itemsDataField: 'totalFixableWarningCount',\n componentsDataField: 'totalComponentsWithFixableWarningCount',\n label: 'FixableWarnings',\n },\n {\n itemsDataField: 'totalWarningCount',\n componentsDataField: 'totalComponentsWithWarningCount',\n label: 'Warnings',\n },\n ];\n\n const summaryTotals = totalFieldsMap\n .map((item) =>\n this.renderTotalLine(lintResults[item.componentsDataField], lintResults[item.itemsDataField], item.label)\n )\n .filter(Boolean)\n .join('\\n');\n const summary = `${summaryTitle}\\n${summaryTotals}`;\n return summary;\n }\n\n private renderTotalLine(componentsCount: number, itemsCount: number, fieldLabel: string): string | undefined {\n if (itemsCount === 0) return undefined;\n return `total of ${chalk.green(itemsCount.toString())} ${chalk.cyan(fieldLabel)} (from ${chalk.green(\n componentsCount.toString()\n )} components)`;\n }\n\n async json([components = []]: [string[]], linterOptions: LintCmdOptions): Promise<JsonLintResults> {\n const timer = Timer.create();\n timer.start();\n const componentsIds = await this.getIdsToLint(components, linterOptions.changed);\n const componentsToLint = await this.workspace.getMany(componentsIds);\n const opts: LinterOptions = {\n fix: linterOptions.fix,\n fixTypes: linterOptions.fixType ? (linterOptions.fixType.split(',') as FixTypes) : undefined,\n };\n const linterResults = await this.linter.lint(componentsToLint, opts);\n const jsonLinterResults = toJsonLintResults(linterResults);\n const timerResponse = timer.stop();\n let code = 0;\n if (jsonLinterResults.totalErrorCount || jsonLinterResults.totalFatalErrorCount) {\n code = 1;\n }\n return {\n code,\n data: {\n duration: timerResponse,\n lintResults: jsonLinterResults,\n componentsIdsToLint: componentsToLint.map((comp) => comp.id.toString()),\n },\n };\n }\n\n private async getIdsToLint(components: string[], changed = false): Promise<ComponentID[]> {\n if (components.length) {\n return this.workspace.resolveMultipleComponentIds(components);\n }\n if (changed) {\n return this.workspace.getNewAndModifiedIds();\n }\n return this.componentHost.listIds();\n }\n}\n\nfunction toJsonLintResults(results: EnvsExecutionResult<LintResults>): JsonLintDataResults {\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 const newResults = results.results.map((res) => {\n const resultsWithoutComponent = res.data?.results.map((result) => {\n return Object.assign({}, { componentId: result.component.id }, omit(result, ['component']));\n });\n\n if (res.data) {\n if (res.data.totalErrorCount) {\n totalErrorCount += res.data.totalErrorCount;\n totalComponentsWithErrorCount += res.data.totalComponentsWithErrorCount ?? 0;\n }\n if (res.data.totalFatalErrorCount) {\n totalFatalErrorCount += res.data.totalFatalErrorCount;\n totalComponentsWithFatalErrorCount += res.data.totalComponentsWithFatalErrorCount ?? 0;\n }\n if (res.data.totalFixableErrorCount) {\n totalFixableErrorCount += res.data.totalFixableErrorCount;\n totalComponentsWithFixableErrorCount += res.data.totalComponentsWithFixableErrorCount ?? 0;\n }\n if (res.data.totalFixableWarningCount) {\n totalFixableWarningCount += res.data.totalFixableWarningCount;\n totalComponentsWithFixableWarningCount += res.data.totalComponentsWithFixableWarningCount ?? 0;\n }\n if (res.data.totalWarningCount) {\n totalWarningCount += res.data.totalWarningCount;\n totalComponentsWithWarningCount += res.data.totalComponentsWithWarningCount ?? 0;\n }\n }\n\n return compact(resultsWithoutComponent);\n });\n return {\n results: compact(flatten(newResults)),\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n totalComponentsWithErrorCount,\n totalComponentsWithFatalErrorCount,\n totalComponentsWithFixableErrorCount,\n totalComponentsWithFixableWarningCount,\n totalComponentsWithWarningCount,\n errors: results?.errors,\n };\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;E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H,IAAI,CAAC0G,iBAAiB;QAC/CK,+BAA+B,IAAIE,GAAG,CAACjH,IAAI,CAAC+G,+BAA+B,IAAI,CAAC;MAClF;IACF;IAEA,OAAO,IAAAS,iBAAO,EAACL,uBAAuB,CAAC;EACzC,CAAC,CAAC;EACF,OAAO;IACLnE,OAAO,EAAE,IAAAwE,iBAAO,EAAC,IAAAC,iBAAO,EAACT,UAAU,CAAC,CAAC;IACrChB,eAAe;IACfC,oBAAoB;IACpBO,sBAAsB;IACtBC,wBAAwB;IACxBC,iBAAiB;IACjBC,6BAA6B;IAC7BC,kCAAkC;IAClCC,oCAAoC;IACpCC,sCAAsC;IACtCC,+BAA+B;IAC/BW,MAAM,EAAE1E,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAE0E;EACnB,CAAC;AACH"}
|
1
|
+
{"version":3,"names":["_timer","data","require","_chalk","_interopRequireDefault","_lodash","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","LintCmd","constructor","linter","componentHost","workspace","report","components","linterOptions","code","json","lintResults","componentsIdsToLint","title","chalk","bold","cyan","length","toString","name","componentsOutputs","results","map","lintRes","compTitle","componentId","ignoreVersion","compOutput","output","join","summary","getSummarySection","duration","seconds","summaryTitle","totalFieldsMap","itemsDataField","componentsDataField","label","summaryTotals","item","renderTotalLine","filter","Boolean","componentsCount","itemsCount","fieldLabel","undefined","green","timer","Timer","create","start","componentsIds","getIdsToLint","changed","componentsToLint","getMany","opts","fix","fixTypes","fixType","split","linterResults","lint","jsonLinterResults","toJsonLintResults","timerResponse","stop","totalErrorCount","totalFatalErrorCount","comp","id","resolveMultipleComponentIds","getNewAndModifiedIds","listIds","exports","totalFixableErrorCount","totalFixableWarningCount","totalWarningCount","totalComponentsWithErrorCount","totalComponentsWithFatalErrorCount","totalComponentsWithFixableErrorCount","totalComponentsWithFixableWarningCount","totalComponentsWithWarningCount","newResults","res","resultsWithoutComponent","result","assign","component","omit","compact","flatten","errors"],"sources":["lint.cmd.ts"],"sourcesContent":["import { TimerResponse, Timer } from '@teambit/legacy/dist/toolbox/timer';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { ComponentFactory, ComponentID } from '@teambit/component';\nimport chalk from 'chalk';\nimport { EnvsExecutionResult } from '@teambit/envs';\nimport { Workspace } from '@teambit/workspace';\nimport { compact, flatten, omit } from 'lodash';\nimport { LinterMain } from './linter.main.runtime';\nimport { ComponentLintResult, LintResults } from './linter';\nimport { FixTypes, LinterOptions } from './linter-context';\n\nexport type LintCmdOptions = {\n changed?: boolean;\n fix?: boolean;\n fixType?: string;\n json?: boolean;\n};\n\n/**\n * A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component\n */\nexport type JsonComponentLintResult = Omit<ComponentLintResult, 'component'> & {\n componentId: ComponentID;\n};\n\nexport type JsonLintDataResults = Omit<LintResults, 'results'> & { results: JsonComponentLintResult[] };\n/**\n * A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component\n */\nexport type JsonLintResultsData = {\n duration: TimerResponse;\n lintResults: JsonLintDataResults;\n componentsIdsToLint: string[];\n};\n\nexport type JsonLintResults = {\n code: number;\n data: JsonLintResultsData;\n};\n\nexport class LintCmd implements Command {\n name = 'lint [component...]';\n description = 'lint components in the development workspace';\n helpUrl = 'reference/linting/linter-overview';\n group = 'development';\n options = [\n ['c', 'changed', 'lint only new and modified components'],\n ['f', 'fix', 'automatically fix problems'],\n ['', 'fix-type <fixType>', 'specify the types of fixes to apply (problem, suggestion, layout)'],\n ['j', 'json', 'return the lint results in json format'],\n ] as CommandOptions;\n\n constructor(private linter: LinterMain, private componentHost: ComponentFactory, private workspace: Workspace) {}\n\n async report([components = []]: [string[]], linterOptions: LintCmdOptions) {\n const { code, data } = await this.json([components], linterOptions);\n const { lintResults, componentsIdsToLint } = data;\n const title = chalk.bold(\n `linting total of ${chalk.cyan(componentsIdsToLint.length.toString())} component(s) in workspace '${chalk.cyan(\n this.componentHost.name\n )}'`\n );\n\n const componentsOutputs = lintResults.results\n .map((lintRes) => {\n const compTitle = chalk.bold.cyan(lintRes.componentId.toString({ ignoreVersion: true }));\n const compOutput = lintRes.output;\n return `${compTitle}\\n${compOutput}`;\n })\n .join('\\n');\n\n const summary = this.getSummarySection(data);\n return { code, data: `${title}\\n\\n${componentsOutputs}\\n\\n${summary}` };\n }\n\n private getSummarySection(data: JsonLintResultsData) {\n const { duration, lintResults, componentsIdsToLint } = data;\n const { seconds } = duration;\n const summaryTitle = `linted ${chalk.cyan(componentsIdsToLint.length.toString())} components in ${chalk.cyan(\n seconds.toString()\n )} seconds`;\n\n const totalFieldsMap = [\n { itemsDataField: 'totalErrorCount', componentsDataField: 'totalComponentsWithErrorCount', label: 'Errors' },\n {\n itemsDataField: 'totalFatalErrorCount',\n componentsDataField: 'totalComponentsWithFatalErrorCount',\n label: 'FatalErrors',\n },\n {\n itemsDataField: 'totalFixableErrorCount',\n componentsDataField: 'totalComponentsWithFixableErrorCount',\n label: 'FixableErrors',\n },\n {\n itemsDataField: 'totalFixableWarningCount',\n componentsDataField: 'totalComponentsWithFixableWarningCount',\n label: 'FixableWarnings',\n },\n {\n itemsDataField: 'totalWarningCount',\n componentsDataField: 'totalComponentsWithWarningCount',\n label: 'Warnings',\n },\n ];\n\n const summaryTotals = totalFieldsMap\n .map((item) =>\n this.renderTotalLine(lintResults[item.componentsDataField], lintResults[item.itemsDataField], item.label)\n )\n .filter(Boolean)\n .join('\\n');\n const summary = `${summaryTitle}\\n${summaryTotals}`;\n return summary;\n }\n\n private renderTotalLine(componentsCount: number, itemsCount: number, fieldLabel: string): string | undefined {\n if (itemsCount === 0) return undefined;\n return `total of ${chalk.green(itemsCount.toString())} ${chalk.cyan(fieldLabel)} (from ${chalk.green(\n componentsCount.toString()\n )} components)`;\n }\n\n async json([components = []]: [string[]], linterOptions: LintCmdOptions): Promise<JsonLintResults> {\n const timer = Timer.create();\n timer.start();\n const componentsIds = await this.getIdsToLint(components, linterOptions.changed);\n const componentsToLint = await this.workspace.getMany(componentsIds);\n const opts: LinterOptions = {\n fix: linterOptions.fix,\n fixTypes: linterOptions.fixType ? (linterOptions.fixType.split(',') as FixTypes) : undefined,\n };\n const linterResults = await this.linter.lint(componentsToLint, opts);\n const jsonLinterResults = toJsonLintResults(linterResults);\n const timerResponse = timer.stop();\n let code = 0;\n if (jsonLinterResults.totalErrorCount || jsonLinterResults.totalFatalErrorCount) {\n code = 1;\n }\n return {\n code,\n data: {\n duration: timerResponse,\n lintResults: jsonLinterResults,\n componentsIdsToLint: componentsToLint.map((comp) => comp.id.toString()),\n },\n };\n }\n\n private async getIdsToLint(components: string[], changed = false): Promise<ComponentID[]> {\n if (components.length) {\n return this.workspace.resolveMultipleComponentIds(components);\n }\n if (changed) {\n return this.workspace.getNewAndModifiedIds();\n }\n return this.componentHost.listIds();\n }\n}\n\nfunction toJsonLintResults(results: EnvsExecutionResult<LintResults>): JsonLintDataResults {\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 const newResults = results.results.map((res) => {\n const resultsWithoutComponent = res.data?.results.map((result) => {\n return Object.assign({}, { componentId: result.component.id }, omit(result, ['component']));\n });\n\n if (res.data) {\n if (res.data.totalErrorCount) {\n totalErrorCount += res.data.totalErrorCount;\n totalComponentsWithErrorCount += res.data.totalComponentsWithErrorCount ?? 0;\n }\n if (res.data.totalFatalErrorCount) {\n totalFatalErrorCount += res.data.totalFatalErrorCount;\n totalComponentsWithFatalErrorCount += res.data.totalComponentsWithFatalErrorCount ?? 0;\n }\n if (res.data.totalFixableErrorCount) {\n totalFixableErrorCount += res.data.totalFixableErrorCount;\n totalComponentsWithFixableErrorCount += res.data.totalComponentsWithFixableErrorCount ?? 0;\n }\n if (res.data.totalFixableWarningCount) {\n totalFixableWarningCount += res.data.totalFixableWarningCount;\n totalComponentsWithFixableWarningCount += res.data.totalComponentsWithFixableWarningCount ?? 0;\n }\n if (res.data.totalWarningCount) {\n totalWarningCount += res.data.totalWarningCount;\n totalComponentsWithWarningCount += res.data.totalComponentsWithWarningCount ?? 0;\n }\n }\n\n return compact(resultsWithoutComponent);\n });\n return {\n results: compact(flatten(newResults)),\n totalErrorCount,\n totalFatalErrorCount,\n totalFixableErrorCount,\n totalFixableWarningCount,\n totalWarningCount,\n totalComponentsWithErrorCount,\n totalComponentsWithFatalErrorCount,\n totalComponentsWithFixableErrorCount,\n totalComponentsWithFixableWarningCount,\n totalComponentsWithWarningCount,\n errors: results?.errors,\n };\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgD,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,E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class LintTask {
|
|
56
56
|
}
|
57
57
|
getComponentsDirectory(capsuleRootDir, components, capsuleList) {
|
58
58
|
return _component().ComponentMap.as(components, component => {
|
59
|
-
|
60
|
-
const fullPath = ((_capsuleList$getCapsu = capsuleList.getCapsule(component.id)) === null || _capsuleList$getCapsu === void 0 ? void 0 : _capsuleList$getCapsu.path) || '';
|
59
|
+
const fullPath = capsuleList.getCapsule(component.id)?.path || '';
|
61
60
|
const relativePath = _path().default.relative(capsuleRootDir, fullPath);
|
62
61
|
return relativePath;
|
63
62
|
});
|
package/dist/lint.task.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_path","data","_interopRequireDefault","require","_component","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","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","
|
1
|
+
{"version":3,"names":["_path","data","_interopRequireDefault","require","_component","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","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","exports"],"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,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA6D,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,E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;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,sBAAsBA,CAC5Ba,cAAsB,EACtBZ,UAAuB,EACvBa,WAAwB,EACF;IACtB,OAAOC,yBAAY,CAACC,EAAE,CAASf,UAAU,EAAGQ,SAAS,IAAK;MACxD,MAAMQ,QAAQ,GAAGH,WAAW,CAACI,UAAU,CAACT,SAAS,CAACU,EAAE,CAAC,EAAEC,IAAI,IAAI,EAAE;MACjE,MAAMC,YAAY,GAAGD,eAAI,CAACE,QAAQ,CAACT,cAAc,EAAEI,QAAQ,CAAC;MAC5D,OAAOI,YAAY;IACrB,CAAC,CAAC;EACJ;AACF;AAACE,OAAA,CAAApC,QAAA,GAAAA,QAAA"}
|
package/dist/linter-context.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ComponentMap } from '@teambit/component';
|
2
2
|
import { ExecutionContext } from '@teambit/envs';
|
3
|
-
export
|
4
|
-
export
|
3
|
+
export type FixType = 'problem' | 'suggestion' | 'layout';
|
4
|
+
export type FixTypes = Array<FixType>;
|
5
5
|
export interface LinterOptions {
|
6
6
|
/**
|
7
7
|
* extensions formats to lint. (e.g. .ts, .tsx, etc.)
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
export declare const Logo: () =>
|
1
|
+
/// <reference types="react" />
|
2
|
+
export declare const Logo: () => JSX.Element;
|
package/dist/linter.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { BuildContext } from '@teambit/builder';
|
2
2
|
import { Component } from '@teambit/component';
|
3
3
|
import { LinterContext } from './linter-context';
|
4
|
-
export
|
4
|
+
export type ComponentLintResult = {
|
5
5
|
/**
|
6
6
|
* the linted component.
|
7
7
|
*/
|
@@ -35,7 +35,7 @@ export declare type ComponentLintResult = {
|
|
35
35
|
*/
|
36
36
|
results: LintResult[];
|
37
37
|
};
|
38
|
-
export
|
38
|
+
export type LintResult = {
|
39
39
|
/**
|
40
40
|
* path of the linted file.
|
41
41
|
*/
|
@@ -69,7 +69,7 @@ export declare type LintResult = {
|
|
69
69
|
*/
|
70
70
|
raw: any;
|
71
71
|
};
|
72
|
-
export
|
72
|
+
export type LintMessage = {
|
73
73
|
/**
|
74
74
|
* severity of the issue.
|
75
75
|
*/
|
@@ -99,7 +99,7 @@ export declare type LintMessage = {
|
|
99
99
|
*/
|
100
100
|
suggestions?: string[];
|
101
101
|
};
|
102
|
-
export
|
102
|
+
export type LintResults = {
|
103
103
|
results: ComponentLintResult[];
|
104
104
|
/**
|
105
105
|
* total errors count of the component (from all of the components).
|
@@ -7,7 +7,7 @@ import { LinterService } from './linter.service';
|
|
7
7
|
import { LintTask } from './lint.task';
|
8
8
|
import { FixTypes, LinterOptions } from './linter-context';
|
9
9
|
import { Linter } from './linter';
|
10
|
-
export
|
10
|
+
export type LinterConfig = {
|
11
11
|
/**
|
12
12
|
* extension formats to lint.
|
13
13
|
*/
|
package/dist/linter.service.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
/// <reference types="react" />
|
2
2
|
import { EnvService, ExecutionContext, EnvDefinition, ServiceTransformationMap, EnvContext, Env } from '@teambit/envs';
|
3
3
|
import { Workspace } from '@teambit/workspace';
|
4
4
|
import { Linter, LintResults } from './linter';
|
5
5
|
import { LinterOptions } from './linter-context';
|
6
6
|
import { LinterConfig } from './linter.main.runtime';
|
7
|
-
|
7
|
+
type LinterTransformationMap = ServiceTransformationMap & {
|
8
8
|
getLinter: () => Linter;
|
9
9
|
};
|
10
10
|
export declare class LinterService implements EnvService<LintResults> {
|
@@ -17,7 +17,7 @@ export declare class LinterService implements EnvService<LintResults> {
|
|
17
17
|
private optionsWithDefaults;
|
18
18
|
private mergeContext;
|
19
19
|
private getComponentsDirectory;
|
20
|
-
render(env: EnvDefinition):
|
20
|
+
render(env: EnvDefinition): JSX.Element;
|
21
21
|
transform(env: Env, context: EnvContext): LinterTransformationMap | undefined;
|
22
22
|
getDescriptor(env: EnvDefinition): {
|
23
23
|
id: any;
|
@@ -25,6 +25,6 @@ export declare class LinterService implements EnvService<LintResults> {
|
|
25
25
|
config: any;
|
26
26
|
version: any;
|
27
27
|
displayName: any;
|
28
|
-
}
|
28
|
+
};
|
29
29
|
}
|
30
30
|
export {};
|
package/dist/linter.service.js
CHANGED
@@ -66,10 +66,9 @@ class LinterService {
|
|
66
66
|
return (0, _lodash().defaults)(options, this.linterConfig);
|
67
67
|
}
|
68
68
|
mergeContext(options, context) {
|
69
|
-
|
70
|
-
const componentsDirMap = context !== null && context !== void 0 && context.components ? this.getComponentsDirectory(context.components) : _component().ComponentMap.create([]);
|
69
|
+
const componentsDirMap = context?.components ? this.getComponentsDirectory(context.components) : _component().ComponentMap.create([]);
|
71
70
|
const linterContext = Object.assign({}, {
|
72
|
-
rootDir:
|
71
|
+
rootDir: this.workspace?.path,
|
73
72
|
quiet: false,
|
74
73
|
extensionFormats: options.extensionFormats,
|
75
74
|
fixTypes: options.fixTypes,
|
@@ -86,19 +85,19 @@ class LinterService {
|
|
86
85
|
render(env) {
|
87
86
|
const descriptor = this.getDescriptor(env);
|
88
87
|
return /*#__PURE__*/_react().default.createElement(_ink().Text, {
|
89
|
-
key: descriptor
|
88
|
+
key: descriptor?.id
|
90
89
|
}, /*#__PURE__*/_react().default.createElement(_ink().Text, {
|
91
90
|
color: "cyan"
|
92
|
-
}, "configured linter: "), /*#__PURE__*/_react().default.createElement(_ink().Text, null, descriptor
|
91
|
+
}, "configured linter: "), /*#__PURE__*/_react().default.createElement(_ink().Text, null, descriptor?.id, " (", descriptor?.displayName, " @ ", descriptor?.version, ")"), /*#__PURE__*/_react().default.createElement(_ink().Newline, null), /*#__PURE__*/_react().default.createElement(_ink().Text, {
|
93
92
|
color: "cyan"
|
94
|
-
}, "linter config:"), /*#__PURE__*/_react().default.createElement(_ink().Newline, null), /*#__PURE__*/_react().default.createElement(_ink().Text, null,
|
93
|
+
}, "linter config:"), /*#__PURE__*/_react().default.createElement(_ink().Newline, null), /*#__PURE__*/_react().default.createElement(_ink().Text, null, descriptor?.config && (0, _cliHighlight().default)(descriptor?.config, {
|
95
94
|
language: 'javascript',
|
96
95
|
ignoreIllegals: true
|
97
96
|
})), /*#__PURE__*/_react().default.createElement(_ink().Newline, null));
|
98
97
|
}
|
99
98
|
transform(env, context) {
|
100
99
|
// Old env
|
101
|
-
if (!
|
100
|
+
if (!env?.linter) return undefined;
|
102
101
|
return {
|
103
102
|
getLinter: () => env.linter()(context)
|
104
103
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","_lodash","_ink","_cliHighlight","_component","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","LinterService","constructor","linterConfig","workspace","run","context","options","mergedOpts","optionsWithDefaults","linterContext","mergeContext","linter","getLinter","results","lint","env","defaults","
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","_lodash","_ink","_cliHighlight","_component","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","LinterService","constructor","linterConfig","workspace","run","context","options","mergedOpts","optionsWithDefaults","linterContext","mergeContext","linter","getLinter","results","lint","env","defaults","componentsDirMap","components","getComponentsDirectory","ComponentMap","create","assign","rootDir","path","quiet","extensionFormats","fixTypes","fix","as","component","componentDir","id","undefined","relative","render","descriptor","getDescriptor","createElement","Text","color","displayName","version","Newline","config","highlight","language","ignoreIllegals","transform","icon","displayConfig","exports"],"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 = this.getLinter(context, options);\n\n const results = await linter.lint(linterContext);\n return results;\n }\n\n getLinter(context: ExecutionContext, options: LinterOptions): Linter {\n const mergedOpts = this.optionsWithDefaults(options);\n const linterContext = this.mergeContext(mergedOpts, context);\n const linter: Linter = context.env.getLinter(linterContext);\n return linter;\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,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,KAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,IAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,cAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,aAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AA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,EAAEV,OAAmB,EAAuC;IAC5E;IACA,IAAI,CAACU,GAAG,EAAEJ,MAAM,EAAE,OAAOsB,SAAS;IAClC,OAAO;MACLrB,SAAS,EAAEA,CAAA,KAAMG,GAAG,CAACJ,MAAM,CAAC,CAAC,CAACN,OAAO;IACvC,CAAC;EACH;EAEAgC,aAAaA,CAACtB,GAAkB,EAAE;IAChC,IAAI,CAACA,GAAG,CAACA,GAAG,CAACH,SAAS,EAAE,OAAOqB,SAAS;IACxC,MAAM1B,UAAU,GAAG,IAAI,CAACC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAC/C,MAAMC,aAAa,GAAG,IAAI,CAACC,YAAY,CAACH,UAAU,CAAC;IACnD,MAAMI,MAAM,GAAGI,GAAG,CAACA,GAAG,CAACH,SAAS,CAACH,aAAa,CAAC;IAE/C,OAAO;MACLuB,EAAE,EAAErB,MAAM,CAACqB,EAAE;MACbiB,IAAI,EAAEtC,MAAM,CAACsC,IAAI;MACjBL,MAAM,EAAEjC,MAAM,CAACuC,aAAa,GAAGvC,MAAM,CAACuC,aAAa,CAAC,CAAC,GAAGjB,SAAS;MACjES,OAAO,EAAE/B,MAAM,CAAC+B,OAAO,GAAG/B,MAAM,CAAC+B,OAAO,CAAC,CAAC,GAAG,GAAG;MAChDD,WAAW,EAAE9B,MAAM,CAAC8B,WAAW,GAAG9B,MAAM,CAAC8B,WAAW,GAAG;IACzD,CAAC;EACH;AACF;AAACU,OAAA,CAAAnD,aAAA,GAAAA,aAAA"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@1.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@1.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@1.0.108/dist/linter.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@1.0.108/dist/linter.docs.mdx';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|
package/index.ts
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
import { LinterAspect } from './linter.aspect';
|
2
|
+
|
3
|
+
export { LinterAspect };
|
4
|
+
export type { LinterMain, LinterConfig } from './linter.main.runtime';
|
5
|
+
export type { LintResults, Linter, LintResult, ComponentLintResult } from './linter';
|
6
|
+
export type { LintTask } from './lint.task';
|
7
|
+
export type { LinterContext, LinterOptions } from './linter-context';
|
8
|
+
export type { LinterEnv } from './linter-env-type';
|
9
|
+
export default LinterAspect;
|
package/lint.cmd.ts
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
import { TimerResponse, Timer } from '@teambit/legacy/dist/toolbox/timer';
|
2
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
3
|
+
import { ComponentFactory, ComponentID } from '@teambit/component';
|
4
|
+
import chalk from 'chalk';
|
5
|
+
import { EnvsExecutionResult } from '@teambit/envs';
|
6
|
+
import { Workspace } from '@teambit/workspace';
|
7
|
+
import { compact, flatten, omit } from 'lodash';
|
8
|
+
import { LinterMain } from './linter.main.runtime';
|
9
|
+
import { ComponentLintResult, LintResults } from './linter';
|
10
|
+
import { FixTypes, LinterOptions } from './linter-context';
|
11
|
+
|
12
|
+
export type LintCmdOptions = {
|
13
|
+
changed?: boolean;
|
14
|
+
fix?: boolean;
|
15
|
+
fixType?: string;
|
16
|
+
json?: boolean;
|
17
|
+
};
|
18
|
+
|
19
|
+
/**
|
20
|
+
* A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component
|
21
|
+
*/
|
22
|
+
export type JsonComponentLintResult = Omit<ComponentLintResult, 'component'> & {
|
23
|
+
componentId: ComponentID;
|
24
|
+
};
|
25
|
+
|
26
|
+
export type JsonLintDataResults = Omit<LintResults, 'results'> & { results: JsonComponentLintResult[] };
|
27
|
+
/**
|
28
|
+
* A type for result with componentId instead of the entire component, as when output to console, we don't want to print all the component
|
29
|
+
*/
|
30
|
+
export type JsonLintResultsData = {
|
31
|
+
duration: TimerResponse;
|
32
|
+
lintResults: JsonLintDataResults;
|
33
|
+
componentsIdsToLint: string[];
|
34
|
+
};
|
35
|
+
|
36
|
+
export type JsonLintResults = {
|
37
|
+
code: number;
|
38
|
+
data: JsonLintResultsData;
|
39
|
+
};
|
40
|
+
|
41
|
+
export class LintCmd implements Command {
|
42
|
+
name = 'lint [component...]';
|
43
|
+
description = 'lint components in the development workspace';
|
44
|
+
helpUrl = 'reference/linting/linter-overview';
|
45
|
+
group = 'development';
|
46
|
+
options = [
|
47
|
+
['c', 'changed', 'lint only new and modified components'],
|
48
|
+
['f', 'fix', 'automatically fix problems'],
|
49
|
+
['', 'fix-type <fixType>', 'specify the types of fixes to apply (problem, suggestion, layout)'],
|
50
|
+
['j', 'json', 'return the lint results in json format'],
|
51
|
+
] as CommandOptions;
|
52
|
+
|
53
|
+
constructor(private linter: LinterMain, private componentHost: ComponentFactory, private workspace: Workspace) {}
|
54
|
+
|
55
|
+
async report([components = []]: [string[]], linterOptions: LintCmdOptions) {
|
56
|
+
const { code, data } = await this.json([components], linterOptions);
|
57
|
+
const { lintResults, componentsIdsToLint } = data;
|
58
|
+
const title = chalk.bold(
|
59
|
+
`linting total of ${chalk.cyan(componentsIdsToLint.length.toString())} component(s) in workspace '${chalk.cyan(
|
60
|
+
this.componentHost.name
|
61
|
+
)}'`
|
62
|
+
);
|
63
|
+
|
64
|
+
const componentsOutputs = lintResults.results
|
65
|
+
.map((lintRes) => {
|
66
|
+
const compTitle = chalk.bold.cyan(lintRes.componentId.toString({ ignoreVersion: true }));
|
67
|
+
const compOutput = lintRes.output;
|
68
|
+
return `${compTitle}\n${compOutput}`;
|
69
|
+
})
|
70
|
+
.join('\n');
|
71
|
+
|
72
|
+
const summary = this.getSummarySection(data);
|
73
|
+
return { code, data: `${title}\n\n${componentsOutputs}\n\n${summary}` };
|
74
|
+
}
|
75
|
+
|
76
|
+
private getSummarySection(data: JsonLintResultsData) {
|
77
|
+
const { duration, lintResults, componentsIdsToLint } = data;
|
78
|
+
const { seconds } = duration;
|
79
|
+
const summaryTitle = `linted ${chalk.cyan(componentsIdsToLint.length.toString())} components in ${chalk.cyan(
|
80
|
+
seconds.toString()
|
81
|
+
)} seconds`;
|
82
|
+
|
83
|
+
const totalFieldsMap = [
|
84
|
+
{ itemsDataField: 'totalErrorCount', componentsDataField: 'totalComponentsWithErrorCount', label: 'Errors' },
|
85
|
+
{
|
86
|
+
itemsDataField: 'totalFatalErrorCount',
|
87
|
+
componentsDataField: 'totalComponentsWithFatalErrorCount',
|
88
|
+
label: 'FatalErrors',
|
89
|
+
},
|
90
|
+
{
|
91
|
+
itemsDataField: 'totalFixableErrorCount',
|
92
|
+
componentsDataField: 'totalComponentsWithFixableErrorCount',
|
93
|
+
label: 'FixableErrors',
|
94
|
+
},
|
95
|
+
{
|
96
|
+
itemsDataField: 'totalFixableWarningCount',
|
97
|
+
componentsDataField: 'totalComponentsWithFixableWarningCount',
|
98
|
+
label: 'FixableWarnings',
|
99
|
+
},
|
100
|
+
{
|
101
|
+
itemsDataField: 'totalWarningCount',
|
102
|
+
componentsDataField: 'totalComponentsWithWarningCount',
|
103
|
+
label: 'Warnings',
|
104
|
+
},
|
105
|
+
];
|
106
|
+
|
107
|
+
const summaryTotals = totalFieldsMap
|
108
|
+
.map((item) =>
|
109
|
+
this.renderTotalLine(lintResults[item.componentsDataField], lintResults[item.itemsDataField], item.label)
|
110
|
+
)
|
111
|
+
.filter(Boolean)
|
112
|
+
.join('\n');
|
113
|
+
const summary = `${summaryTitle}\n${summaryTotals}`;
|
114
|
+
return summary;
|
115
|
+
}
|
116
|
+
|
117
|
+
private renderTotalLine(componentsCount: number, itemsCount: number, fieldLabel: string): string | undefined {
|
118
|
+
if (itemsCount === 0) return undefined;
|
119
|
+
return `total of ${chalk.green(itemsCount.toString())} ${chalk.cyan(fieldLabel)} (from ${chalk.green(
|
120
|
+
componentsCount.toString()
|
121
|
+
)} components)`;
|
122
|
+
}
|
123
|
+
|
124
|
+
async json([components = []]: [string[]], linterOptions: LintCmdOptions): Promise<JsonLintResults> {
|
125
|
+
const timer = Timer.create();
|
126
|
+
timer.start();
|
127
|
+
const componentsIds = await this.getIdsToLint(components, linterOptions.changed);
|
128
|
+
const componentsToLint = await this.workspace.getMany(componentsIds);
|
129
|
+
const opts: LinterOptions = {
|
130
|
+
fix: linterOptions.fix,
|
131
|
+
fixTypes: linterOptions.fixType ? (linterOptions.fixType.split(',') as FixTypes) : undefined,
|
132
|
+
};
|
133
|
+
const linterResults = await this.linter.lint(componentsToLint, opts);
|
134
|
+
const jsonLinterResults = toJsonLintResults(linterResults);
|
135
|
+
const timerResponse = timer.stop();
|
136
|
+
let code = 0;
|
137
|
+
if (jsonLinterResults.totalErrorCount || jsonLinterResults.totalFatalErrorCount) {
|
138
|
+
code = 1;
|
139
|
+
}
|
140
|
+
return {
|
141
|
+
code,
|
142
|
+
data: {
|
143
|
+
duration: timerResponse,
|
144
|
+
lintResults: jsonLinterResults,
|
145
|
+
componentsIdsToLint: componentsToLint.map((comp) => comp.id.toString()),
|
146
|
+
},
|
147
|
+
};
|
148
|
+
}
|
149
|
+
|
150
|
+
private async getIdsToLint(components: string[], changed = false): Promise<ComponentID[]> {
|
151
|
+
if (components.length) {
|
152
|
+
return this.workspace.resolveMultipleComponentIds(components);
|
153
|
+
}
|
154
|
+
if (changed) {
|
155
|
+
return this.workspace.getNewAndModifiedIds();
|
156
|
+
}
|
157
|
+
return this.componentHost.listIds();
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
function toJsonLintResults(results: EnvsExecutionResult<LintResults>): JsonLintDataResults {
|
162
|
+
let totalErrorCount = 0;
|
163
|
+
let totalFatalErrorCount = 0;
|
164
|
+
let totalFixableErrorCount = 0;
|
165
|
+
let totalFixableWarningCount = 0;
|
166
|
+
let totalWarningCount = 0;
|
167
|
+
let totalComponentsWithErrorCount = 0;
|
168
|
+
let totalComponentsWithFatalErrorCount = 0;
|
169
|
+
let totalComponentsWithFixableErrorCount = 0;
|
170
|
+
let totalComponentsWithFixableWarningCount = 0;
|
171
|
+
let totalComponentsWithWarningCount = 0;
|
172
|
+
|
173
|
+
const newResults = results.results.map((res) => {
|
174
|
+
const resultsWithoutComponent = res.data?.results.map((result) => {
|
175
|
+
return Object.assign({}, { componentId: result.component.id }, omit(result, ['component']));
|
176
|
+
});
|
177
|
+
|
178
|
+
if (res.data) {
|
179
|
+
if (res.data.totalErrorCount) {
|
180
|
+
totalErrorCount += res.data.totalErrorCount;
|
181
|
+
totalComponentsWithErrorCount += res.data.totalComponentsWithErrorCount ?? 0;
|
182
|
+
}
|
183
|
+
if (res.data.totalFatalErrorCount) {
|
184
|
+
totalFatalErrorCount += res.data.totalFatalErrorCount;
|
185
|
+
totalComponentsWithFatalErrorCount += res.data.totalComponentsWithFatalErrorCount ?? 0;
|
186
|
+
}
|
187
|
+
if (res.data.totalFixableErrorCount) {
|
188
|
+
totalFixableErrorCount += res.data.totalFixableErrorCount;
|
189
|
+
totalComponentsWithFixableErrorCount += res.data.totalComponentsWithFixableErrorCount ?? 0;
|
190
|
+
}
|
191
|
+
if (res.data.totalFixableWarningCount) {
|
192
|
+
totalFixableWarningCount += res.data.totalFixableWarningCount;
|
193
|
+
totalComponentsWithFixableWarningCount += res.data.totalComponentsWithFixableWarningCount ?? 0;
|
194
|
+
}
|
195
|
+
if (res.data.totalWarningCount) {
|
196
|
+
totalWarningCount += res.data.totalWarningCount;
|
197
|
+
totalComponentsWithWarningCount += res.data.totalComponentsWithWarningCount ?? 0;
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
return compact(resultsWithoutComponent);
|
202
|
+
});
|
203
|
+
return {
|
204
|
+
results: compact(flatten(newResults)),
|
205
|
+
totalErrorCount,
|
206
|
+
totalFatalErrorCount,
|
207
|
+
totalFixableErrorCount,
|
208
|
+
totalFixableWarningCount,
|
209
|
+
totalWarningCount,
|
210
|
+
totalComponentsWithErrorCount,
|
211
|
+
totalComponentsWithFatalErrorCount,
|
212
|
+
totalComponentsWithFixableErrorCount,
|
213
|
+
totalComponentsWithFixableWarningCount,
|
214
|
+
totalComponentsWithWarningCount,
|
215
|
+
errors: results?.errors,
|
216
|
+
};
|
217
|
+
}
|
package/lint.task.ts
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
import path from 'path';
|
2
|
+
import { BuildTask, BuiltTaskResult, BuildContext, ComponentResult } from '@teambit/builder';
|
3
|
+
import { Component, ComponentMap } from '@teambit/component';
|
4
|
+
import { CapsuleList } from '@teambit/isolator';
|
5
|
+
import { Linter } from './linter';
|
6
|
+
import { LinterContext } from './linter-context';
|
7
|
+
|
8
|
+
export class LintTask implements BuildTask {
|
9
|
+
constructor(readonly aspectId: string, readonly name = 'lint') {}
|
10
|
+
|
11
|
+
async execute(context: BuildContext): Promise<BuiltTaskResult> {
|
12
|
+
const linter: Linter = context.env.getLinter();
|
13
|
+
const rootDir = context.capsuleNetwork.capsulesRootDir;
|
14
|
+
const componentsDirMap = this.getComponentsDirectory(
|
15
|
+
rootDir,
|
16
|
+
context.components,
|
17
|
+
context.capsuleNetwork.graphCapsules
|
18
|
+
);
|
19
|
+
|
20
|
+
// @ts-ignore TODO: fix this
|
21
|
+
const linterContext: LinterContext = {
|
22
|
+
rootDir,
|
23
|
+
componentsDirMap,
|
24
|
+
...context,
|
25
|
+
};
|
26
|
+
const results = await linter.lint(linterContext);
|
27
|
+
const componentsResults = results.results.map((lintResult): ComponentResult => {
|
28
|
+
return {
|
29
|
+
component: lintResult.component,
|
30
|
+
metadata: {
|
31
|
+
output: lintResult.output,
|
32
|
+
results: lintResult.results,
|
33
|
+
},
|
34
|
+
errors: [],
|
35
|
+
};
|
36
|
+
});
|
37
|
+
|
38
|
+
return {
|
39
|
+
componentsResults,
|
40
|
+
};
|
41
|
+
}
|
42
|
+
|
43
|
+
private getComponentsDirectory(
|
44
|
+
capsuleRootDir: string,
|
45
|
+
components: Component[],
|
46
|
+
capsuleList: CapsuleList
|
47
|
+
): ComponentMap<string> {
|
48
|
+
return ComponentMap.as<string>(components, (component) => {
|
49
|
+
const fullPath = capsuleList.getCapsule(component.id)?.path || '';
|
50
|
+
const relativePath = path.relative(capsuleRootDir, fullPath);
|
51
|
+
return relativePath;
|
52
|
+
});
|
53
|
+
}
|
54
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { ComponentMap } from '@teambit/component';
|
2
|
+
import { ExecutionContext } from '@teambit/envs';
|
3
|
+
|
4
|
+
export type FixType = 'problem' | 'suggestion' | 'layout';
|
5
|
+
export type FixTypes = Array<FixType>;
|
6
|
+
|
7
|
+
export interface LinterOptions {
|
8
|
+
/**
|
9
|
+
* extensions formats to lint. (e.g. .ts, .tsx, etc.)
|
10
|
+
*/
|
11
|
+
extensionFormats?: string[];
|
12
|
+
|
13
|
+
/**
|
14
|
+
* automatically fix problems
|
15
|
+
*/
|
16
|
+
fix?: boolean;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* specify the types of fixes to apply (problem, suggestion, layout)
|
20
|
+
*/
|
21
|
+
fixTypes?: FixTypes;
|
22
|
+
}
|
23
|
+
export interface LinterContext extends ExecutionContext, LinterOptions {
|
24
|
+
quiet?: boolean;
|
25
|
+
/**
|
26
|
+
* Root dir that contains all the components in the fs that are about to be linted
|
27
|
+
* Usually it's the workspace root dir or the capsule root dir
|
28
|
+
*/
|
29
|
+
rootDir?: string;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Component map with the path to the component in the fs
|
33
|
+
*/
|
34
|
+
componentsDirMap: ComponentMap<string>;
|
35
|
+
}
|
package/linter.aspect.ts
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
|
2
|
+
import { Component, ComponentAspect, ComponentMain } from '@teambit/component';
|
3
|
+
import { EnvsAspect, EnvsMain, ExecutionContext } from '@teambit/envs';
|
4
|
+
import { LoggerAspect, LoggerMain } from '@teambit/logger';
|
5
|
+
import { Workspace, WorkspaceAspect } from '@teambit/workspace';
|
6
|
+
import { LinterAspect } from './linter.aspect';
|
7
|
+
import { LinterService } from './linter.service';
|
8
|
+
import { LintTask } from './lint.task';
|
9
|
+
import { LintCmd } from './lint.cmd';
|
10
|
+
import { FixTypes, LinterOptions } from './linter-context';
|
11
|
+
import { Linter } from './linter';
|
12
|
+
|
13
|
+
export type LinterConfig = {
|
14
|
+
/**
|
15
|
+
* extension formats to lint.
|
16
|
+
*/
|
17
|
+
extensionFormats: string[];
|
18
|
+
fixTypes?: FixTypes;
|
19
|
+
};
|
20
|
+
|
21
|
+
export class LinterMain {
|
22
|
+
static runtime = MainRuntime;
|
23
|
+
|
24
|
+
constructor(private envs: EnvsMain, private linterService: LinterService) {}
|
25
|
+
|
26
|
+
/**
|
27
|
+
* lint an array of components.
|
28
|
+
*/
|
29
|
+
async lint(components: Component[], opts: LinterOptions) {
|
30
|
+
const envsRuntime = await this.envs.createEnvironment(components);
|
31
|
+
const lintResults = envsRuntime.run(this.linterService, opts);
|
32
|
+
return lintResults;
|
33
|
+
}
|
34
|
+
|
35
|
+
getLinter(context: ExecutionContext, options: LinterOptions): Linter {
|
36
|
+
return this.linterService.getLinter(context, options);
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* create a lint task for build pipelines.
|
41
|
+
* @param name name of the task.
|
42
|
+
*/
|
43
|
+
createTask(name?: string): LintTask {
|
44
|
+
return new LintTask(LinterAspect.id, name);
|
45
|
+
}
|
46
|
+
|
47
|
+
static dependencies = [EnvsAspect, CLIAspect, ComponentAspect, LoggerAspect, WorkspaceAspect];
|
48
|
+
|
49
|
+
static defaultConfig: LinterConfig = {
|
50
|
+
extensionFormats: ['.ts', '.tsx', '.js', '.jsx', '.mjs'],
|
51
|
+
fixTypes: ['layout', 'problem', 'suggestion'],
|
52
|
+
};
|
53
|
+
|
54
|
+
static async provider(
|
55
|
+
[envs, cli, component, loggerAspect, workspace]: [EnvsMain, CLIMain, ComponentMain, LoggerMain, Workspace],
|
56
|
+
config: LinterConfig
|
57
|
+
) {
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
59
|
+
const logger = loggerAspect.createLogger(LinterAspect.id);
|
60
|
+
const linterService = new LinterService(config, workspace);
|
61
|
+
const linterAspect = new LinterMain(envs, linterService);
|
62
|
+
envs.registerService(linterService);
|
63
|
+
cli.register(new LintCmd(linterAspect, component.getHost(), workspace));
|
64
|
+
|
65
|
+
return linterAspect;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
LinterAspect.addRuntime(LinterMain);
|
package/linter.ts
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
import { BuildContext } from '@teambit/builder';
|
2
|
+
import { Component } from '@teambit/component';
|
3
|
+
import { LinterContext } from './linter-context';
|
4
|
+
|
5
|
+
export type ComponentLintResult = {
|
6
|
+
/**
|
7
|
+
* the linted component.
|
8
|
+
*/
|
9
|
+
component: Component;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* CLI output of the linter.
|
13
|
+
*/
|
14
|
+
output: string;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* total errors count of the component (from all of the files).
|
18
|
+
*/
|
19
|
+
totalErrorCount: number;
|
20
|
+
/**
|
21
|
+
* total fatal errors count of the component (from all of the files).
|
22
|
+
*/
|
23
|
+
totalFatalErrorCount?: number;
|
24
|
+
/**
|
25
|
+
* total fixable errors count of the component (from all of the files).
|
26
|
+
*/
|
27
|
+
totalFixableErrorCount?: number;
|
28
|
+
/**
|
29
|
+
* total fatal warning count of the component (from all of the files).
|
30
|
+
*/
|
31
|
+
totalFixableWarningCount?: number;
|
32
|
+
/**
|
33
|
+
* total warning count of the component (from all of the files).
|
34
|
+
*/
|
35
|
+
totalWarningCount: number;
|
36
|
+
|
37
|
+
/**
|
38
|
+
* lint results for each one of the component files
|
39
|
+
*/
|
40
|
+
results: LintResult[];
|
41
|
+
};
|
42
|
+
|
43
|
+
export type LintResult = {
|
44
|
+
/**
|
45
|
+
* path of the linted file.
|
46
|
+
*/
|
47
|
+
filePath: string;
|
48
|
+
|
49
|
+
/**
|
50
|
+
* numbers of errors found.
|
51
|
+
*/
|
52
|
+
errorCount: number;
|
53
|
+
|
54
|
+
/**
|
55
|
+
* numbers of errors found.
|
56
|
+
*/
|
57
|
+
fatalErrorCount?: number;
|
58
|
+
|
59
|
+
/**
|
60
|
+
* numbers of fixable errors found.
|
61
|
+
*/
|
62
|
+
fixableErrorCount?: number;
|
63
|
+
|
64
|
+
/**
|
65
|
+
* numbers of fixable warning found.
|
66
|
+
*/
|
67
|
+
fixableWarningCount?: number;
|
68
|
+
|
69
|
+
/**
|
70
|
+
* number of found warnings.
|
71
|
+
*/
|
72
|
+
warningCount: number;
|
73
|
+
|
74
|
+
/**
|
75
|
+
* lint messages.
|
76
|
+
*/
|
77
|
+
messages: LintMessage[];
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Raw data as returned from the linter
|
81
|
+
*/
|
82
|
+
raw: any;
|
83
|
+
};
|
84
|
+
|
85
|
+
export type LintMessage = {
|
86
|
+
/**
|
87
|
+
* severity of the issue.
|
88
|
+
*/
|
89
|
+
severity: string;
|
90
|
+
/**
|
91
|
+
* stating column of the issue.
|
92
|
+
*/
|
93
|
+
column: number;
|
94
|
+
|
95
|
+
/**
|
96
|
+
* line of the issue.
|
97
|
+
*/
|
98
|
+
line: number;
|
99
|
+
|
100
|
+
/**
|
101
|
+
* end column of the issue.
|
102
|
+
*/
|
103
|
+
endColumn?: number;
|
104
|
+
|
105
|
+
/**
|
106
|
+
* end line of the issue.
|
107
|
+
*/
|
108
|
+
endLine?: number;
|
109
|
+
|
110
|
+
/**
|
111
|
+
* message of the issue.
|
112
|
+
*/
|
113
|
+
message: string;
|
114
|
+
|
115
|
+
/**
|
116
|
+
* lint suggestions.
|
117
|
+
*/
|
118
|
+
suggestions?: string[];
|
119
|
+
};
|
120
|
+
|
121
|
+
export type LintResults = {
|
122
|
+
results: ComponentLintResult[];
|
123
|
+
/**
|
124
|
+
* total errors count of the component (from all of the components).
|
125
|
+
*/
|
126
|
+
totalErrorCount: number;
|
127
|
+
/**
|
128
|
+
* total fatal errors count of the component (from all of the components).
|
129
|
+
*/
|
130
|
+
totalFatalErrorCount?: number;
|
131
|
+
/**
|
132
|
+
* total fixable errors count of the component (from all of the components).
|
133
|
+
*/
|
134
|
+
totalFixableErrorCount?: number;
|
135
|
+
/**
|
136
|
+
* total fatal warning count of the component (from all of the components).
|
137
|
+
*/
|
138
|
+
totalFixableWarningCount?: number;
|
139
|
+
/**
|
140
|
+
* total warning count of the component (from all of the components).
|
141
|
+
*/
|
142
|
+
totalWarningCount: number;
|
143
|
+
|
144
|
+
totalComponentsWithErrorCount: number;
|
145
|
+
totalComponentsWithFatalErrorCount?: number;
|
146
|
+
totalComponentsWithFixableErrorCount?: number;
|
147
|
+
totalComponentsWithFixableWarningCount?: number;
|
148
|
+
totalComponentsWithWarningCount: number;
|
149
|
+
|
150
|
+
errors: Error[];
|
151
|
+
};
|
152
|
+
|
153
|
+
export interface Linter {
|
154
|
+
id: string;
|
155
|
+
lint(context: LinterContext, buildContext?: BuildContext): Promise<LintResults>;
|
156
|
+
}
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/linter",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.108",
|
4
4
|
"homepage": "https://bit.cloud/teambit/defender/linter",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"componentId": {
|
7
7
|
"scope": "teambit.defender",
|
8
8
|
"name": "linter",
|
9
|
-
"version": "1.0.
|
9
|
+
"version": "1.0.108"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"chalk": "2.4.2",
|
@@ -14,31 +14,27 @@
|
|
14
14
|
"graphql-tag": "2.12.1",
|
15
15
|
"cli-highlight": "2.1.9",
|
16
16
|
"ink": "3.2.0",
|
17
|
-
"core-js": "^3.0.0",
|
18
|
-
"@babel/runtime": "7.20.0",
|
19
17
|
"@teambit/harmony": "0.4.6",
|
20
|
-
"@teambit/cli": "0.0.
|
21
|
-
"@teambit/component": "1.0.
|
22
|
-
"@teambit/envs": "1.0.
|
23
|
-
"@teambit/workspace": "1.0.
|
24
|
-
"@teambit/builder": "1.0.
|
25
|
-
"@teambit/isolator": "1.0.
|
26
|
-
"@teambit/logger": "0.0.
|
18
|
+
"@teambit/cli": "0.0.840",
|
19
|
+
"@teambit/component": "1.0.108",
|
20
|
+
"@teambit/envs": "1.0.108",
|
21
|
+
"@teambit/workspace": "1.0.108",
|
22
|
+
"@teambit/builder": "1.0.108",
|
23
|
+
"@teambit/isolator": "1.0.108",
|
24
|
+
"@teambit/logger": "0.0.933"
|
27
25
|
},
|
28
26
|
"devDependencies": {
|
29
27
|
"@types/lodash": "4.14.165",
|
30
|
-
"@types/react": "^17.0.8",
|
31
28
|
"@types/mocha": "9.1.0",
|
32
|
-
"@types/
|
33
|
-
"@types/
|
34
|
-
"@
|
35
|
-
"@
|
36
|
-
"@teambit/defender.content.linter-overview": "1.95.0"
|
29
|
+
"@types/jest": "^29.2.2",
|
30
|
+
"@types/testing-library__jest-dom": "^5.9.5",
|
31
|
+
"@teambit/defender.content.linter-overview": "1.95.0",
|
32
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.13"
|
37
33
|
},
|
38
34
|
"peerDependencies": {
|
39
|
-
"
|
40
|
-
"react": "^
|
41
|
-
"
|
35
|
+
"react": "^17.0.0 || ^18.0.0",
|
36
|
+
"@types/react": "^18.2.12",
|
37
|
+
"@teambit/legacy": "1.0.624"
|
42
38
|
},
|
43
39
|
"license": "Apache-2.0",
|
44
40
|
"optionalDependencies": {},
|
@@ -52,7 +48,7 @@
|
|
52
48
|
},
|
53
49
|
"private": false,
|
54
50
|
"engines": {
|
55
|
-
"node": ">=
|
51
|
+
"node": ">=16.0.0"
|
56
52
|
},
|
57
53
|
"repository": {
|
58
54
|
"type": "git",
|
@@ -61,12 +57,9 @@
|
|
61
57
|
"keywords": [
|
62
58
|
"bit",
|
63
59
|
"bit-aspect",
|
60
|
+
"bit-core-aspect",
|
64
61
|
"components",
|
65
62
|
"collaboration",
|
66
|
-
"web"
|
67
|
-
"react",
|
68
|
-
"react-components",
|
69
|
-
"angular",
|
70
|
-
"angular-components"
|
63
|
+
"web"
|
71
64
|
]
|
72
65
|
}
|
package/tsconfig.json
CHANGED
@@ -1,38 +1,33 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"lib": [
|
4
|
-
"
|
5
|
-
"
|
6
|
-
"
|
7
|
-
"DOM.Iterable",
|
8
|
-
"ScriptHost"
|
4
|
+
"esnext",
|
5
|
+
"dom",
|
6
|
+
"dom.Iterable"
|
9
7
|
],
|
10
|
-
"target": "
|
11
|
-
"module": "
|
12
|
-
"jsx": "react",
|
13
|
-
"allowJs": true,
|
14
|
-
"composite": true,
|
8
|
+
"target": "es2020",
|
9
|
+
"module": "es2020",
|
10
|
+
"jsx": "react-jsx",
|
15
11
|
"declaration": true,
|
16
12
|
"sourceMap": true,
|
17
|
-
"skipLibCheck": true,
|
18
13
|
"experimentalDecorators": true,
|
19
|
-
"
|
14
|
+
"skipLibCheck": true,
|
20
15
|
"moduleResolution": "node",
|
21
16
|
"esModuleInterop": true,
|
22
|
-
"rootDir": ".",
|
23
17
|
"resolveJsonModule": true,
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"strictPropertyInitialization": false,
|
28
|
-
"strict": true,
|
29
|
-
"noImplicitAny": false,
|
30
|
-
"preserveConstEnums": true
|
18
|
+
"allowJs": true,
|
19
|
+
"outDir": "dist",
|
20
|
+
"emitDeclarationOnly": true
|
31
21
|
},
|
32
22
|
"exclude": [
|
23
|
+
"artifacts",
|
24
|
+
"public",
|
33
25
|
"dist",
|
26
|
+
"node_modules",
|
27
|
+
"package.json",
|
34
28
|
"esm.mjs",
|
35
|
-
"
|
29
|
+
"**/*.cjs",
|
30
|
+
"./dist"
|
36
31
|
],
|
37
32
|
"include": [
|
38
33
|
"**/*",
|
package/types/asset.d.ts
CHANGED
@@ -5,12 +5,12 @@ declare module '*.png' {
|
|
5
5
|
declare module '*.svg' {
|
6
6
|
import type { FunctionComponent, SVGProps } from 'react';
|
7
7
|
|
8
|
-
export const ReactComponent: FunctionComponent<
|
8
|
+
export const ReactComponent: FunctionComponent<
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
10
|
+
>;
|
9
11
|
const src: string;
|
10
12
|
export default src;
|
11
13
|
}
|
12
|
-
|
13
|
-
// @TODO Gilad
|
14
14
|
declare module '*.jpg' {
|
15
15
|
const value: any;
|
16
16
|
export = value;
|
@@ -27,3 +27,15 @@ declare module '*.bmp' {
|
|
27
27
|
const value: any;
|
28
28
|
export = value;
|
29
29
|
}
|
30
|
+
declare module '*.otf' {
|
31
|
+
const value: any;
|
32
|
+
export = value;
|
33
|
+
}
|
34
|
+
declare module '*.woff' {
|
35
|
+
const value: any;
|
36
|
+
export = value;
|
37
|
+
}
|
38
|
+
declare module '*.woff2' {
|
39
|
+
const value: any;
|
40
|
+
export = value;
|
41
|
+
}
|