@teambit/linter 1.0.309 → 1.0.310

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.js CHANGED
@@ -69,17 +69,28 @@ class LintCmd {
69
69
  componentsIdsToLint
70
70
  } = data;
71
71
  const title = _chalk().default.bold(`linting total of ${_chalk().default.cyan(componentsIdsToLint.length.toString())} component(s) in workspace '${_chalk().default.cyan(this.componentHost.name)}'`);
72
- const componentsOutputs = lintResults.results.map(lintRes => {
72
+ const groupedByIsClean = (0, _lodash().groupBy)(lintResults.results, res => {
73
+ if (res.isClean !== undefined) {
74
+ return res.isClean;
75
+ }
76
+ // The is clean field was added in a later version of the linter, so if it's not there, we will calculate it
77
+ // based on the errors/warnings count
78
+ return res.totalErrorCount + (res.totalFatalErrorCount || 0) + res.totalWarningCount === 0;
79
+ });
80
+ const dirtyComponentsOutputs = (groupedByIsClean.false || []).map(lintRes => {
73
81
  const compTitle = _chalk().default.bold.cyan(lintRes.componentId.toString({
74
82
  ignoreVersion: true
75
83
  }));
76
84
  const compOutput = lintRes.output;
77
85
  return `${compTitle}\n${compOutput}`;
78
86
  }).join('\n');
87
+ const cleanComponentsCount = groupedByIsClean.true?.length || 0;
88
+ const cleanComponentsOutput = cleanComponentsCount ? `total of ${_chalk().default.green(cleanComponentsCount.toString())} component(s) has no linting issues` : '';
79
89
  const summary = this.getSummarySection(data);
90
+ const finalOutput = (0, _lodash().compact)([title, dirtyComponentsOutputs, cleanComponentsOutput, summary]).join('\n\n');
80
91
  return {
81
92
  code,
82
- data: `${title}\n\n${componentsOutputs}\n\n${summary}`
93
+ data: finalOutput
83
94
  };
84
95
  }
85
96
  getSummarySection(data) {
@@ -198,6 +209,7 @@ function toJsonLintResults(results) {
198
209
  }
199
210
  return (0, _lodash().compact)(resultsWithoutComponent);
200
211
  });
212
+ const isClean = totalComponentsWithErrorCount === 0 && totalComponentsWithWarningCount === 0 && totalComponentsWithFatalErrorCount === 0;
201
213
  return {
202
214
  results: (0, _lodash().compact)((0, _lodash().flatten)(newResults)),
203
215
  totalErrorCount,
@@ -210,6 +222,7 @@ function toJsonLintResults(results) {
210
222
  totalComponentsWithFixableErrorCount,
211
223
  totalComponentsWithFixableWarningCount,
212
224
  totalComponentsWithWarningCount,
225
+ isClean,
213
226
  errors: results?.errors
214
227
  };
215
228
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_timer","data","require","_constants","_chalk","_interopRequireDefault","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LintCmd","constructor","linter","componentHost","workspace","name","description","COMPONENT_PATTERN_HELP","report","pattern","linterOptions","code","json","lintResults","componentsIdsToLint","title","chalk","bold","cyan","length","toString","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","idsByPattern","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 { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';\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-pattern]';\n description = 'lint components in the development workspace';\n arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];\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([pattern]: [string], linterOptions: LintCmdOptions) {\n const { code, data } = await this.json([pattern], 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([pattern]: [string], linterOptions: LintCmdOptions): Promise<JsonLintResults> {\n const timer = Timer.create();\n timer.start();\n const componentsIds = await this.getIdsToLint(pattern, 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(pattern: string, changed = false): Promise<ComponentID[]> {\n if (pattern) {\n return this.workspace.idsByPattern(pattern);\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;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAgD,SAAAI,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YA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","_constants","_chalk","_interopRequireDefault","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LintCmd","constructor","linter","componentHost","workspace","name","description","COMPONENT_PATTERN_HELP","report","pattern","linterOptions","code","json","lintResults","componentsIdsToLint","title","chalk","bold","cyan","length","toString","groupedByIsClean","groupBy","results","res","isClean","undefined","totalErrorCount","totalFatalErrorCount","totalWarningCount","dirtyComponentsOutputs","false","map","lintRes","compTitle","componentId","ignoreVersion","compOutput","output","join","cleanComponentsCount","true","cleanComponentsOutput","green","summary","getSummarySection","finalOutput","compact","duration","seconds","summaryTitle","totalFieldsMap","itemsDataField","componentsDataField","label","summaryTotals","item","renderTotalLine","filter","Boolean","componentsCount","itemsCount","fieldLabel","timer","Timer","create","start","componentsIds","getIdsToLint","changed","componentsToLint","getMany","opts","fix","fixTypes","fixType","split","linterResults","lint","jsonLinterResults","toJsonLintResults","timerResponse","stop","comp","id","idsByPattern","getNewAndModifiedIds","listIds","exports","totalFixableErrorCount","totalFixableWarningCount","totalComponentsWithErrorCount","totalComponentsWithFatalErrorCount","totalComponentsWithFixableErrorCount","totalComponentsWithFixableWarningCount","totalComponentsWithWarningCount","newResults","resultsWithoutComponent","result","assign","component","omit","flatten","errors"],"sources":["lint.cmd.ts"],"sourcesContent":["import { TimerResponse, Timer } from '@teambit/legacy/dist/toolbox/timer';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';\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, groupBy, 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-pattern]';\n description = 'lint components in the development workspace';\n arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];\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([pattern]: [string], linterOptions: LintCmdOptions) {\n const { code, data } = await this.json([pattern], 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 groupedByIsClean = groupBy(lintResults.results, (res) => {\n if (res.isClean !== undefined) {\n return res.isClean;\n }\n // The is clean field was added in a later version of the linter, so if it's not there, we will calculate it\n // based on the errors/warnings count\n return res.totalErrorCount + (res.totalFatalErrorCount || 0) + res.totalWarningCount === 0;\n });\n\n const dirtyComponentsOutputs = (groupedByIsClean.false || [])\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 cleanComponentsCount = groupedByIsClean.true?.length || 0;\n const cleanComponentsOutput = cleanComponentsCount\n ? `total of ${chalk.green(cleanComponentsCount.toString())} component(s) has no linting issues`\n : '';\n\n const summary = this.getSummarySection(data);\n const finalOutput = compact([title, dirtyComponentsOutputs, cleanComponentsOutput, summary]).join('\\n\\n');\n return { code, data: finalOutput };\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([pattern]: [string], linterOptions: LintCmdOptions): Promise<JsonLintResults> {\n const timer = Timer.create();\n timer.start();\n const componentsIds = await this.getIdsToLint(pattern, 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(pattern: string, changed = false): Promise<ComponentID[]> {\n if (pattern) {\n return this.workspace.idsByPattern(pattern);\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\n const isClean =\n totalComponentsWithErrorCount === 0 &&\n totalComponentsWithWarningCount === 0 &&\n totalComponentsWithFatalErrorCount === 0;\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 isClean,\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;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAH,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAyD,SAAAI,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,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AAE;QACnCA,sBAAsB,IAAIjE,GAAG,CAACnD,IAAI,CAACoH,sBAAsB;QACzDI,oCAAoC,IAAIrE,GAAG,CAACnD,IAAI,CAACwH,oCAAoC,IAAI,CAAC;MAC5F;MACA,IAAIrE,GAAG,CAACnD,IAAI,CAACqH,wBAAwB,EAAE;QACrCA,wBAAwB,IAAIlE,GAAG,CAACnD,IAAI,CAACqH,wBAAwB;QAC7DI,sCAAsC,IAAItE,GAAG,CAACnD,IAAI,CAACyH,sCAAsC,IAAI,CAAC;MAChG;MACA,IAAItE,GAAG,CAACnD,IAAI,CAACwD,iBAAiB,EAAE;QAC9BA,iBAAiB,IAAIL,GAAG,CAACnD,IAAI,CAACwD,iBAAiB;QAC/CkE,+BAA+B,IAAIvE,GAAG,CAACnD,IAAI,CAAC0H,+BAA+B,IAAI,CAAC;MAClF;IACF;IAEA,OAAO,IAAAhD,iBAAO,EAACkD,uBAAuB,CAAC;EACzC,CAAC,CAAC;EAEF,MAAMxE,OAAO,GACXkE,6BAA6B,KAAK,CAAC,IACnCI,+BAA+B,KAAK,CAAC,IACrCH,kCAAkC,KAAK,CAAC;EAE1C,OAAO;IACLrE,OAAO,EAAE,IAAAwB,iBAAO,EAAC,IAAAuD,iBAAO,EAACN,UAAU,CAAC,CAAC;IACrCrE,eAAe;IACfC,oBAAoB;IACpB6D,sBAAsB;IACtBC,wBAAwB;IACxB7D,iBAAiB;IACjB8D,6BAA6B;IAC7BC,kCAAkC;IAClCC,oCAAoC;IACpCC,sCAAsC;IACtCC,+BAA+B;IAC/BtE,OAAO;IACP8E,MAAM,EAAEhF,OAAO,EAAEgF;EACnB,CAAC;AACH","ignoreList":[]}
package/dist/linter.d.ts CHANGED
@@ -30,6 +30,10 @@ export type ComponentLintResult = {
30
30
  * total warning count of the component (from all of the files).
31
31
  */
32
32
  totalWarningCount: number;
33
+ /**
34
+ * whether the component is clean (have no issues at all)
35
+ */
36
+ isClean: boolean;
33
37
  /**
34
38
  * lint results for each one of the component files
35
39
  */
@@ -126,6 +130,10 @@ export type LintResults = {
126
130
  totalComponentsWithFixableErrorCount?: number;
127
131
  totalComponentsWithFixableWarningCount?: number;
128
132
  totalComponentsWithWarningCount: number;
133
+ /**
134
+ * whether all the linted components is clean (have no issues at all)
135
+ */
136
+ isClean: boolean;
129
137
  errors: Error[];
130
138
  };
131
139
  export interface Linter {
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["linter.ts"],"sourcesContent":["import { BuildContext } from '@teambit/builder';\nimport { Component } from '@teambit/component';\nimport { LinterContext } from './linter-context';\n\nexport type ComponentLintResult = {\n /**\n * the linted component.\n */\n component: Component;\n\n /**\n * CLI output of the linter.\n */\n output: string;\n\n /**\n * total errors count of the component (from all of the files).\n */\n totalErrorCount: number;\n /**\n * total fatal errors count of the component (from all of the files).\n */\n totalFatalErrorCount?: number;\n /**\n * total fixable errors count of the component (from all of the files).\n */\n totalFixableErrorCount?: number;\n /**\n * total fatal warning count of the component (from all of the files).\n */\n totalFixableWarningCount?: number;\n /**\n * total warning count of the component (from all of the files).\n */\n totalWarningCount: number;\n\n /**\n * lint results for each one of the component files\n */\n results: LintResult[];\n};\n\nexport type LintResult = {\n /**\n * path of the linted file.\n */\n filePath: string;\n\n /**\n * numbers of errors found.\n */\n errorCount: number;\n\n /**\n * numbers of errors found.\n */\n fatalErrorCount?: number;\n\n /**\n * numbers of fixable errors found.\n */\n fixableErrorCount?: number;\n\n /**\n * numbers of fixable warning found.\n */\n fixableWarningCount?: number;\n\n /**\n * number of found warnings.\n */\n warningCount: number;\n\n /**\n * lint messages.\n */\n messages: LintMessage[];\n\n /**\n * Raw data as returned from the linter\n */\n raw: any;\n};\n\nexport type LintMessage = {\n /**\n * severity of the issue.\n */\n severity: string;\n /**\n * stating column of the issue.\n */\n column: number;\n\n /**\n * line of the issue.\n */\n line: number;\n\n /**\n * end column of the issue.\n */\n endColumn?: number;\n\n /**\n * end line of the issue.\n */\n endLine?: number;\n\n /**\n * message of the issue.\n */\n message: string;\n\n /**\n * lint suggestions.\n */\n suggestions?: string[];\n};\n\nexport type LintResults = {\n results: ComponentLintResult[];\n /**\n * total errors count of the component (from all of the components).\n */\n totalErrorCount: number;\n /**\n * total fatal errors count of the component (from all of the components).\n */\n totalFatalErrorCount?: number;\n /**\n * total fixable errors count of the component (from all of the components).\n */\n totalFixableErrorCount?: number;\n /**\n * total fatal warning count of the component (from all of the components).\n */\n totalFixableWarningCount?: number;\n /**\n * total warning count of the component (from all of the components).\n */\n totalWarningCount: number;\n\n totalComponentsWithErrorCount: number;\n totalComponentsWithFatalErrorCount?: number;\n totalComponentsWithFixableErrorCount?: number;\n totalComponentsWithFixableWarningCount?: number;\n totalComponentsWithWarningCount: number;\n\n errors: Error[];\n};\n\nexport interface Linter {\n id: string;\n lint(context: LinterContext, buildContext?: BuildContext): Promise<LintResults>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["linter.ts"],"sourcesContent":["import { BuildContext } from '@teambit/builder';\nimport { Component } from '@teambit/component';\nimport { LinterContext } from './linter-context';\n\nexport type ComponentLintResult = {\n /**\n * the linted component.\n */\n component: Component;\n\n /**\n * CLI output of the linter.\n */\n output: string;\n\n /**\n * total errors count of the component (from all of the files).\n */\n totalErrorCount: number;\n /**\n * total fatal errors count of the component (from all of the files).\n */\n totalFatalErrorCount?: number;\n /**\n * total fixable errors count of the component (from all of the files).\n */\n totalFixableErrorCount?: number;\n /**\n * total fatal warning count of the component (from all of the files).\n */\n totalFixableWarningCount?: number;\n /**\n * total warning count of the component (from all of the files).\n */\n totalWarningCount: number;\n\n /**\n * whether the component is clean (have no issues at all)\n */\n isClean: boolean;\n\n /**\n * lint results for each one of the component files\n */\n results: LintResult[];\n};\n\nexport type LintResult = {\n /**\n * path of the linted file.\n */\n filePath: string;\n\n /**\n * numbers of errors found.\n */\n errorCount: number;\n\n /**\n * numbers of errors found.\n */\n fatalErrorCount?: number;\n\n /**\n * numbers of fixable errors found.\n */\n fixableErrorCount?: number;\n\n /**\n * numbers of fixable warning found.\n */\n fixableWarningCount?: number;\n\n /**\n * number of found warnings.\n */\n warningCount: number;\n\n /**\n * lint messages.\n */\n messages: LintMessage[];\n\n /**\n * Raw data as returned from the linter\n */\n raw: any;\n};\n\nexport type LintMessage = {\n /**\n * severity of the issue.\n */\n severity: string;\n /**\n * stating column of the issue.\n */\n column: number;\n\n /**\n * line of the issue.\n */\n line: number;\n\n /**\n * end column of the issue.\n */\n endColumn?: number;\n\n /**\n * end line of the issue.\n */\n endLine?: number;\n\n /**\n * message of the issue.\n */\n message: string;\n\n /**\n * lint suggestions.\n */\n suggestions?: string[];\n};\n\nexport type LintResults = {\n results: ComponentLintResult[];\n /**\n * total errors count of the component (from all of the components).\n */\n totalErrorCount: number;\n /**\n * total fatal errors count of the component (from all of the components).\n */\n totalFatalErrorCount?: number;\n /**\n * total fixable errors count of the component (from all of the components).\n */\n totalFixableErrorCount?: number;\n /**\n * total fatal warning count of the component (from all of the components).\n */\n totalFixableWarningCount?: number;\n /**\n * total warning count of the component (from all of the components).\n */\n totalWarningCount: number;\n\n totalComponentsWithErrorCount: number;\n totalComponentsWithFatalErrorCount?: number;\n totalComponentsWithFixableErrorCount?: number;\n totalComponentsWithFixableWarningCount?: number;\n totalComponentsWithWarningCount: number;\n\n /**\n * whether all the linted components is clean (have no issues at all)\n */\n isClean: boolean;\n\n errors: Error[];\n};\n\nexport interface Linter {\n id: string;\n lint(context: LinterContext, buildContext?: BuildContext): Promise<LintResults>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.defender_linter@1.0.309/dist/linter.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.defender_linter@1.0.309/dist/linter.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.defender_linter@1.0.310/dist/linter.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.defender_linter@1.0.310/dist/linter.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/linter",
3
- "version": "1.0.309",
3
+ "version": "1.0.310",
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.309"
9
+ "version": "1.0.310"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -14,13 +14,13 @@
14
14
  "graphql-tag": "2.12.1",
15
15
  "cli-highlight": "2.1.9",
16
16
  "@teambit/harmony": "0.4.6",
17
- "@teambit/cli": "0.0.886",
18
- "@teambit/component": "1.0.309",
19
- "@teambit/envs": "1.0.309",
20
- "@teambit/workspace": "1.0.309",
21
- "@teambit/builder": "1.0.309",
22
- "@teambit/isolator": "1.0.309",
23
- "@teambit/logger": "0.0.979"
17
+ "@teambit/cli": "0.0.887",
18
+ "@teambit/component": "1.0.310",
19
+ "@teambit/envs": "1.0.310",
20
+ "@teambit/workspace": "1.0.310",
21
+ "@teambit/builder": "1.0.310",
22
+ "@teambit/isolator": "1.0.310",
23
+ "@teambit/logger": "0.0.980"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/lodash": "4.14.165",