@teambit/linter 1.0.209 → 1.0.210

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.
@@ -1,4 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <testsuites tests="0" failures="0" errors="0" skipped="0">
3
- <testsuite name="teambit.defender/linter@1.0.209" tests="0" failures="0" errors="0" skipped="0"/>
3
+ <testsuite name="teambit.defender/linter@1.0.210" tests="0" failures="0" errors="0" skipped="0"/>
4
4
  </testsuites>
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["teambit.defender/linter-preview"]=n():e["teambit.defender/linter-preview"]=n()}(self,(()=>(()=>{"use strict";var e={1278:(e,n,t)=>{Object.defineProperty(n,"Ay",{enumerable:!0,get:function(){return o.default}});var o=r(t(73141));function r(e){return e&&e.__esModule?e:{default:e}}r.__bit_component={id:"teambit.defender/content/linter-overview@1.95.0",homepage:"https://bit.dev/teambit/defender/content/linter-overview",exported:!0}},73141:(e,n,t)=>{var o={id:"teambit.defender/content/linter-overview@1.95.0",homepage:"https://bit.dev/teambit/defender/content/linter-overview",exported:!0};Object.defineProperty(n,"__esModule",{value:!0}),n.default=c,p(t(41594));var r=t(5016),i=t(65682),a=["components"];function p(e){return e&&e.__esModule?e:{default:e}}function d(){return d=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},d.apply(this,arguments)}function l(e,n){if(null==e)return{};var t,o,r=s(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}function s(e,n){if(null==e)return{};var t,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||(r[t]=e[t]);return r}p.__bit_component=o,d.__bit_component=o,l.__bit_component=o,s.__bit_component=o;var m={},u="wrapper";function c(e){var n=e.components,t=l(e,a);return(0,r.mdx)(u,d({},m,t,{components:n,mdxType:"MDXLayout"}),(0,r.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"},(0,r.mdx)("h1",null,"Overview"),(0,r.mdx)("p",null,"Linting helps us maintain consistent code styling and avoid potential bugs by analyzing our source code, statically, before it is compiled and executed."),(0,r.mdx)("p",null,"The Linter aspect simplifies and standardizes the process of component linting. It does so for linting during development (in the workspace) and for linting during component build (in a capsule, as part of the ",(0,r.mdx)("a",{parentName:"p",href:"/builder/build-pipelines"},"Build Pipeline"),")"),(0,r.mdx)("h2",null,"Linting in development"),(0,r.mdx)("p",null,"Bit lints all components in the ",(0,r.mdx)("a",{parentName:"p",href:"/workspace/overview"},"Workspace")," using just a single command. That is true for components of all types, regardless of their specific ",(0,r.mdx)("a",{parentName:"p",href:"/envs/overview"},"Env"),", and as a consequence of that, their specific Linter implementation"," and configuration."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-bash"},"bit lint\n")),(0,r.mdx)("p",null,"To learn more on linting during development, please refer to ",(0,r.mdx)("a",{parentName:"p",href:"/linter/workspace-linting"},"Workspace Linting"),"."),(0,r.mdx)("h2",null,"Linting during build"),(0,r.mdx)("p",null,"During build, the lint task is only used for checking linting issues. it will not re-write the components with the auto fix option."),(0,r.mdx)("p",null,"Testing components for distribution is done during ",(0,r.mdx)("inlineCode",{parentName:"p"},"build")," by the Bit ",(0,r.mdx)("a",{parentName:"p",href:"/builder/overview"},"Builder"),"."),(0,r.mdx)("p",null,"Component build can be simulated with ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit build")," and done through ",(0,r.mdx)("a",{parentName:"p",href:"/components/tags"},"Tag")," or ",(0,r.mdx)("a",{parentName:"p",href:"/components/snaps"},"Snap")),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-bash"},"bit build\n")),(0,r.mdx)("p",null,"By default, linting is ",(0,r.mdx)("strong",{parentName:"p"},"not")," part of the ",(0,r.mdx)("a",{parentName:"p",href:"/builder/build-pipelines"},"Build Pipeline"),"."),(0,r.mdx)("h2",null,"Configuring and implementing Linters"),(0,r.mdx)("p",null,"The Linter implementation"," is configured in the ",(0,r.mdx)("a",{parentName:"p",href:"/envs/overview"},"Env")," which is configured on your ",(0,r.mdx)("a",{parentName:"p",href:"/components/overview"},"Component"),". Customizing it can be done by ",(0,r.mdx)("a",{parentName:"p",href:"/"},"customizing an existing env with your linter")," or by ",(0,r.mdx)("a",{parentName:"p",href:"/envs/customizing-env"},"implementing your own Env"),"."),(0,r.mdx)("p",null,"Linter can also be implemented into Bit through few interfaces. ")))}c.__bit_component=o,c.isMDXComponent=!0},99683:(e,n,t)=>{var o={id:"teambit.defender/linter@1.0.209",homepage:"https://bit.cloud/teambit/defender/linter",exported:!0};function r(){const e=i(t(41594));return r=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Logo=void 0,r.__bit_component=o,i.__bit_component=o;const a=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/linter.svg"}));a.__bit_component=o,n.Logo=a},5016:e=>{e.exports=MdxJsReact},41594:e=>{e.exports=React},65682:e=>{e.exports=TeambitMdxUiMdxScopeContext}},n={};function t(o){var r=n[o];if(void 0!==r)return r.exports;var i=n[o]={exports:{}};return e[o](i,i.exports,t),i.exports}t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{t.r(o),t.d(o,{compositions:()=>u,compositions_metadata:()=>f,overview:()=>c});var e={};t.r(e),t.d(e,{default:()=>m});var n=t(99683),r=(t(41594),t(5016)),i=t(65682),a=t(1278),p=["components"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},d.apply(this,arguments)}var l={},s="wrapper";function m(e){var n=e.components,t=function(e,n){if(null==e)return{};var t,o,r=function(e,n){if(null==e)return{};var t,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}(e,p);return(0,r.mdx)(s,d({},l,t,{components:n,mdxType:"MDXLayout"}),(0,r.mdx)(i.MDXScopeProvider,{components:{LinterOverview:a.Ay},mdxType:"MDXScopeProvider"},(0,r.mdx)(a.Ay,{mdxType:"LinterOverview"})))}m.isMDXComponent=!0;const u=[n],c=[e],f={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),o})()));
1
+ !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["teambit.defender/linter-preview"]=n():e["teambit.defender/linter-preview"]=n()}(self,(()=>(()=>{"use strict";var e={19484:(e,n,t)=>{Object.defineProperty(n,"Ay",{enumerable:!0,get:function(){return o.default}});var o=r(t(823));function r(e){return e&&e.__esModule?e:{default:e}}r.__bit_component={id:"teambit.defender/content/linter-overview@1.95.0",homepage:"https://bit.dev/teambit/defender/content/linter-overview",exported:!0}},823:(e,n,t)=>{var o={id:"teambit.defender/content/linter-overview@1.95.0",homepage:"https://bit.dev/teambit/defender/content/linter-overview",exported:!0};Object.defineProperty(n,"__esModule",{value:!0}),n.default=c,p(t(41594));var r=t(5016),i=t(65682),a=["components"];function p(e){return e&&e.__esModule?e:{default:e}}function d(){return d=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},d.apply(this,arguments)}function l(e,n){if(null==e)return{};var t,o,r=s(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}function s(e,n){if(null==e)return{};var t,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||(r[t]=e[t]);return r}p.__bit_component=o,d.__bit_component=o,l.__bit_component=o,s.__bit_component=o;var m={},u="wrapper";function c(e){var n=e.components,t=l(e,a);return(0,r.mdx)(u,d({},m,t,{components:n,mdxType:"MDXLayout"}),(0,r.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"},(0,r.mdx)("h1",null,"Overview"),(0,r.mdx)("p",null,"Linting helps us maintain consistent code styling and avoid potential bugs by analyzing our source code, statically, before it is compiled and executed."),(0,r.mdx)("p",null,"The Linter aspect simplifies and standardizes the process of component linting. It does so for linting during development (in the workspace) and for linting during component build (in a capsule, as part of the ",(0,r.mdx)("a",{parentName:"p",href:"/builder/build-pipelines"},"Build Pipeline"),")"),(0,r.mdx)("h2",null,"Linting in development"),(0,r.mdx)("p",null,"Bit lints all components in the ",(0,r.mdx)("a",{parentName:"p",href:"/workspace/overview"},"Workspace")," using just a single command. That is true for components of all types, regardless of their specific ",(0,r.mdx)("a",{parentName:"p",href:"/envs/overview"},"Env"),", and as a consequence of that, their specific Linter implementation"," and configuration."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-bash"},"bit lint\n")),(0,r.mdx)("p",null,"To learn more on linting during development, please refer to ",(0,r.mdx)("a",{parentName:"p",href:"/linter/workspace-linting"},"Workspace Linting"),"."),(0,r.mdx)("h2",null,"Linting during build"),(0,r.mdx)("p",null,"During build, the lint task is only used for checking linting issues. it will not re-write the components with the auto fix option."),(0,r.mdx)("p",null,"Testing components for distribution is done during ",(0,r.mdx)("inlineCode",{parentName:"p"},"build")," by the Bit ",(0,r.mdx)("a",{parentName:"p",href:"/builder/overview"},"Builder"),"."),(0,r.mdx)("p",null,"Component build can be simulated with ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit build")," and done through ",(0,r.mdx)("a",{parentName:"p",href:"/components/tags"},"Tag")," or ",(0,r.mdx)("a",{parentName:"p",href:"/components/snaps"},"Snap")),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-bash"},"bit build\n")),(0,r.mdx)("p",null,"By default, linting is ",(0,r.mdx)("strong",{parentName:"p"},"not")," part of the ",(0,r.mdx)("a",{parentName:"p",href:"/builder/build-pipelines"},"Build Pipeline"),"."),(0,r.mdx)("h2",null,"Configuring and implementing Linters"),(0,r.mdx)("p",null,"The Linter implementation"," is configured in the ",(0,r.mdx)("a",{parentName:"p",href:"/envs/overview"},"Env")," which is configured on your ",(0,r.mdx)("a",{parentName:"p",href:"/components/overview"},"Component"),". Customizing it can be done by ",(0,r.mdx)("a",{parentName:"p",href:"/"},"customizing an existing env with your linter")," or by ",(0,r.mdx)("a",{parentName:"p",href:"/envs/customizing-env"},"implementing your own Env"),"."),(0,r.mdx)("p",null,"Linter can also be implemented into Bit through few interfaces. ")))}c.__bit_component=o,c.isMDXComponent=!0},84911:(e,n,t)=>{var o={id:"teambit.defender/linter@1.0.210",homepage:"https://bit.cloud/teambit/defender/linter",exported:!0};function r(){const e=i(t(41594));return r=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Logo=void 0,r.__bit_component=o,i.__bit_component=o;const a=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/linter.svg"}));a.__bit_component=o,n.Logo=a},5016:e=>{e.exports=MdxJsReact},41594:e=>{e.exports=React},65682:e=>{e.exports=TeambitMdxUiMdxScopeContext}},n={};function t(o){var r=n[o];if(void 0!==r)return r.exports;var i=n[o]={exports:{}};return e[o](i,i.exports,t),i.exports}t.d=(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{t.r(o),t.d(o,{compositions:()=>u,compositions_metadata:()=>f,overview:()=>c});var e={};t.r(e),t.d(e,{default:()=>m});var n=t(84911),r=(t(41594),t(5016)),i=t(65682),a=t(19484),p=["components"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},d.apply(this,arguments)}var l={},s="wrapper";function m(e){var n=e.components,t=function(e,n){if(null==e)return{};var t,o,r=function(e,n){if(null==e)return{};var t,o,r={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}(e,p);return(0,r.mdx)(s,d({},l,t,{components:n,mdxType:"MDXLayout"}),(0,r.mdx)(i.MDXScopeProvider,{components:{LinterOverview:a.Ay},mdxType:"MDXScopeProvider"},(0,r.mdx)(a.Ay,{mdxType:"LinterOverview"})))}m.isMDXComponent=!0;const u=[n],c=[e],f={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),o})()));
@@ -1747,7 +1747,7 @@
1747
1747
  "_legacy": {
1748
1748
  "scope": "teambit.defender",
1749
1749
  "name": "linter",
1750
- "version": "1.0.209"
1750
+ "version": "1.0.210"
1751
1751
  },
1752
1752
  "_scope": "teambit.defender"
1753
1753
  }
@@ -1883,7 +1883,7 @@
1883
1883
  "_legacy": {
1884
1884
  "scope": "teambit.defender",
1885
1885
  "name": "linter",
1886
- "version": "1.0.209"
1886
+ "version": "1.0.210"
1887
1887
  },
1888
1888
  "_scope": "teambit.defender"
1889
1889
  }
@@ -4222,7 +4222,7 @@
4222
4222
  "_legacy": {
4223
4223
  "scope": "teambit.defender",
4224
4224
  "name": "linter",
4225
- "version": "1.0.209"
4225
+ "version": "1.0.210"
4226
4226
  },
4227
4227
  "_scope": "teambit.defender"
4228
4228
  }
@@ -4559,7 +4559,7 @@
4559
4559
  "_legacy": {
4560
4560
  "scope": "teambit.defender",
4561
4561
  "name": "linter",
4562
- "version": "1.0.209"
4562
+ "version": "1.0.210"
4563
4563
  },
4564
4564
  "_scope": "teambit.defender"
4565
4565
  }
@@ -4766,7 +4766,7 @@
4766
4766
  "componentId": {
4767
4767
  "scope": "teambit.defender",
4768
4768
  "name": "linter",
4769
- "version": "1.0.209"
4769
+ "version": "1.0.210"
4770
4770
  },
4771
4771
  "taggedModuleExports": []
4772
4772
  }
package/dist/lint.cmd.js CHANGED
@@ -34,7 +34,7 @@ function _lodash() {
34
34
  }
35
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
36
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
37
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
38
38
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
39
39
  /**
40
40
  * 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
@@ -1 +1 @@
1
- {"version":3,"names":["_timer","data","require","_constants","_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","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,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,EAAAA,KAAA,E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reList":[]}
1
+ {"version":3,"names":["_timer","data","require","_constants","_chalk","_interopRequireDefault","_lodash","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","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,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,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAG,CAAA,2BA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+G,kCAAkC,IAAI,CAAC;MACxF;MACA,IAAIK,GAAG,CAACpH,IAAI,CAAC2G,sBAAsB,EAAE;QACnCA,sBAAsB,IAAIS,GAAG,CAACpH,IAAI,CAAC2G,sBAAsB;QACzDK,oCAAoC,IAAII,GAAG,CAACpH,IAAI,CAACgH,oCAAoC,IAAI,CAAC;MAC5F;MACA,IAAII,GAAG,CAACpH,IAAI,CAAC4G,wBAAwB,EAAE;QACrCA,wBAAwB,IAAIQ,GAAG,CAACpH,IAAI,CAAC4G,wBAAwB;QAC7DK,sCAAsC,IAAIG,GAAG,CAACpH,IAAI,CAACiH,sCAAsC,IAAI,CAAC;MAChG;MACA,IAAIG,GAAG,CAACpH,IAAI,CAAC6G,iBAAiB,EAAE;QAC9BA,iBAAiB,IAAIO,GAAG,CAACpH,IAAI,CAAC6G,iBAAiB;QAC/CK,+BAA+B,IAAIE,GAAG,CAACpH,IAAI,CAACkH,+BAA+B,IAAI,CAAC;MAClF;IACF;IAEA,OAAO,IAAAQ,iBAAO,EAACL,uBAAuB,CAAC;EACzC,CAAC,CAAC;EACF,OAAO;IACLlE,OAAO,EAAE,IAAAuE,iBAAO,EAAC,IAAAC,iBAAO,EAACR,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/BU,MAAM,EAAEzE,OAAO,EAAEyE;EACnB,CAAC;AACH","ignoreList":[]}
package/dist/lint.task.js CHANGED
@@ -22,7 +22,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
24
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
25
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
26
26
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
27
  class LintTask {
28
28
  constructor(aspectId, name = 'lint') {
@@ -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","originalSeedersCapsules","linterContext","results","lint","componentsResults","map","lintResult","component","metadata","output","errors","capsuleRootDir","capsuleList","ComponentMap","as","getAllComponents","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 { 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(rootDir, context.capsuleNetwork.originalSeedersCapsules);\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(capsuleRootDir: string, capsuleList: CapsuleList): ComponentMap<string> {\n return ComponentMap.as<string>(capsuleList.getAllComponents(), (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;AAAkD,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,C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BP,OAAO,EAAEI,UAAU,CAACJ;QACtB,CAAC;QACDQ,MAAM,EAAE;MACV,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;MACLN;IACF,CAAC;EACH;EAEQL,sBAAsBA,CAACY,cAAsB,EAAEC,WAAwB,EAAwB;IACrG,OAAOC,yBAAY,CAACC,EAAE,CAASF,WAAW,CAACG,gBAAgB,CAAC,CAAC,EAAGR,SAAS,IAAK;MAC5E,MAAMS,QAAQ,GAAGJ,WAAW,CAACK,UAAU,CAACV,SAAS,CAACW,EAAE,CAAC,EAAEC,IAAI,IAAI,EAAE;MACjE,MAAMC,YAAY,GAAGD,eAAI,CAACE,QAAQ,CAACV,cAAc,EAAEK,QAAQ,CAAC;MAC5D,OAAOI,YAAY;IACrB,CAAC,CAAC;EACJ;AACF;AAACE,OAAA,CAAApC,QAAA,GAAAA,QAAA","ignoreList":[]}
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","Symbol","toPrimitive","call","TypeError","String","Number","LintTask","constructor","aspectId","name","execute","context","linter","env","getLinter","rootDir","capsuleNetwork","capsulesRootDir","componentsDirMap","getComponentsDirectory","originalSeedersCapsules","linterContext","results","lint","componentsResults","map","lintResult","component","metadata","output","errors","capsuleRootDir","capsuleList","ComponentMap","as","getAllComponents","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 { 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(rootDir, context.capsuleNetwork.originalSeedersCapsules);\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(capsuleRootDir: string, capsuleList: CapsuleList): ComponentMap<string> {\n return ComponentMap.as<string>(capsuleList.getAllComponents(), (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;AAAkD,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CA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AAY,CAACC,EAAE,CAASF,WAAW,CAACG,gBAAgB,CAAC,CAAC,EAAGR,SAAS,IAAK;MAC5E,MAAMS,QAAQ,GAAGJ,WAAW,CAACK,UAAU,CAACV,SAAS,CAACW,EAAE,CAAC,EAAEC,IAAI,IAAI,EAAE;MACjE,MAAMC,YAAY,GAAGD,eAAI,CAACE,QAAQ,CAACV,cAAc,EAAEK,QAAQ,CAAC;MAC5D,OAAOI,YAAY;IACrB,CAAC,CAAC;EACJ;AACF;AAACE,OAAA,CAAApC,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -68,7 +68,7 @@ function _lint2() {
68
68
  return data;
69
69
  }
70
70
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
71
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
71
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
72
72
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
73
73
  class LinterMain {
74
74
  constructor(envs, linterService) {
@@ -1 +1 @@
1
- {"version":3,"names":["_cli","data","require","_component","_envs","_logger","_workspace","_linter","_linter2","_lint","_lint2","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","LinterMain","constructor","envs","linterService","lint","components","opts","envsRuntime","createEnvironment","lintResults","run","getLinter","context","options","createTask","name","LintTask","LinterAspect","id","provider","cli","component","loggerAspect","workspace","config","logger","createLogger","LinterService","linterAspect","registerService","register","LintCmd","getHost","exports","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","LoggerAspect","WorkspaceAspect","extensionFormats","fixTypes","addRuntime"],"sources":["linter.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain } from '@teambit/component';\nimport { EnvsAspect, EnvsMain, ExecutionContext } from '@teambit/envs';\nimport { LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { LinterAspect } from './linter.aspect';\nimport { LinterService } from './linter.service';\nimport { LintTask } from './lint.task';\nimport { LintCmd } from './lint.cmd';\nimport { FixTypes, LinterOptions } from './linter-context';\nimport { Linter } from './linter';\n\nexport type LinterConfig = {\n /**\n * extension formats to lint.\n */\n extensionFormats: string[];\n fixTypes?: FixTypes;\n};\n\nexport class LinterMain {\n static runtime = MainRuntime;\n\n constructor(private envs: EnvsMain, private linterService: LinterService) {}\n\n /**\n * lint an array of components.\n */\n async lint(components: Component[], opts: LinterOptions) {\n const envsRuntime = await this.envs.createEnvironment(components);\n const lintResults = envsRuntime.run(this.linterService, opts);\n return lintResults;\n }\n\n getLinter(context: ExecutionContext, options: LinterOptions): Linter {\n return this.linterService.getLinter(context, options);\n }\n\n /**\n * create a lint task for build pipelines.\n * @param name name of the task.\n */\n createTask(name?: string): LintTask {\n return new LintTask(LinterAspect.id, name);\n }\n\n static dependencies = [EnvsAspect, CLIAspect, ComponentAspect, LoggerAspect, WorkspaceAspect];\n\n static defaultConfig: LinterConfig = {\n extensionFormats: ['.ts', '.tsx', '.js', '.jsx', '.mjs'],\n fixTypes: ['layout', 'problem', 'suggestion'],\n };\n\n static async provider(\n [envs, cli, component, loggerAspect, workspace]: [EnvsMain, CLIMain, ComponentMain, LoggerMain, Workspace],\n config: LinterConfig\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const logger = loggerAspect.createLogger(LinterAspect.id);\n const linterService = new LinterService(config, workspace);\n const linterAspect = new LinterMain(envs, linterService);\n envs.registerService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","data","require","_component","_envs","_logger","_workspace","_linter","_linter2","_lint","_lint2","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","LinterMain","constructor","envs","linterService","lint","components","opts","envsRuntime","createEnvironment","lintResults","run","getLinter","context","options","createTask","name","LintTask","LinterAspect","id","provider","cli","component","loggerAspect","workspace","config","logger","createLogger","LinterService","linterAspect","registerService","register","LintCmd","getHost","exports","MainRuntime","EnvsAspect","CLIAspect","ComponentAspect","LoggerAspect","WorkspaceAspect","extensionFormats","fixTypes","addRuntime"],"sources":["linter.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain } from '@teambit/component';\nimport { EnvsAspect, EnvsMain, ExecutionContext } from '@teambit/envs';\nimport { LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { LinterAspect } from './linter.aspect';\nimport { LinterService } from './linter.service';\nimport { LintTask } from './lint.task';\nimport { LintCmd } from './lint.cmd';\nimport { FixTypes, LinterOptions } from './linter-context';\nimport { Linter } from './linter';\n\nexport type LinterConfig = {\n /**\n * extension formats to lint.\n */\n extensionFormats: string[];\n fixTypes?: FixTypes;\n};\n\nexport class LinterMain {\n static runtime = MainRuntime;\n\n constructor(private envs: EnvsMain, private linterService: LinterService) {}\n\n /**\n * lint an array of components.\n */\n async lint(components: Component[], opts: LinterOptions) {\n const envsRuntime = await this.envs.createEnvironment(components);\n const lintResults = envsRuntime.run(this.linterService, opts);\n return lintResults;\n }\n\n getLinter(context: ExecutionContext, options: LinterOptions): Linter {\n return this.linterService.getLinter(context, options);\n }\n\n /**\n * create a lint task for build pipelines.\n * @param name name of the task.\n */\n createTask(name?: string): LintTask {\n return new LintTask(LinterAspect.id, name);\n }\n\n static dependencies = [EnvsAspect, CLIAspect, ComponentAspect, LoggerAspect, WorkspaceAspect];\n\n static defaultConfig: LinterConfig = {\n extensionFormats: ['.ts', '.tsx', '.js', '.jsx', '.mjs'],\n fixTypes: ['layout', 'problem', 'suggestion'],\n };\n\n static async provider(\n [envs, cli, component, loggerAspect, workspace]: [EnvsMain, CLIMain, ComponentMain, LoggerMain, Workspace],\n config: LinterConfig\n ) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const logger = loggerAspect.createLogger(LinterAspect.id);\n const linterService = new LinterService(config, workspace);\n const linterAspect = new LinterMain(envs, linterService);\n envs.registerService(linterService);\n cli.register(new LintCmd(linterAspect, component.getHost(), workspace));\n\n return linterAspect;\n }\n}\n\nLinterAspect.addRuntime(LinterMain);\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,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;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,SA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AAe,EAAEC,sBAAY,EAAEC,4BAAe,CAAC;AAAA5D,eAAA,CA1BlFqB,UAAU,mBA4BgB;EACnCwC,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;EACxDC,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY;AAC9C,CAAC;AAiBHxB,sBAAY,CAACyB,UAAU,CAAC1C,UAAU,CAAC","ignoreList":[]}
@@ -34,7 +34,7 @@ function _component() {
34
34
  }
35
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
36
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
37
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
38
38
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
39
39
  class LinterService {
40
40
  constructor(linterConfig, workspace) {
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_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","name","chalk","green","displayName","version","configLabel","configObj","config","highlight","language","ignoreIllegals","transform","icon","displayConfig","exports"],"sources":["linter.service.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { defaults } from 'lodash';\nimport { EnvService, ExecutionContext, EnvDefinition, ServiceTransformationMap, EnvContext, Env } from '@teambit/envs';\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 const name = `${chalk.green('configured linter:')} ${descriptor?.id} (${descriptor?.displayName} @ ${\n descriptor?.version\n })`;\n const configLabel = chalk.green('linter config:');\n const configObj = descriptor?.config\n ? highlight(descriptor?.config, { language: 'json', ignoreIllegals: true })\n : '';\n return `${name}\\n${configLabel}\\n${configObj}`;\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;AAGA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA6D,SAAAC,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;A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ACwC,aAAa,CAAC,CAAC,GAAGlB,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;AAACW,OAAA,CAAApD,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_cliHighlight","_component","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","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","name","chalk","green","displayName","version","configLabel","configObj","config","highlight","language","ignoreIllegals","transform","icon","displayConfig","exports"],"sources":["linter.service.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { defaults } from 'lodash';\nimport { EnvService, ExecutionContext, EnvDefinition, ServiceTransformationMap, EnvContext, Env } from '@teambit/envs';\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 const name = `${chalk.green('configured linter:')} ${descriptor?.id} (${descriptor?.displayName} @ ${\n descriptor?.version\n })`;\n const configLabel = chalk.green('linter config:');\n const configObj = descriptor?.config\n ? highlight(descriptor?.config, { language: 'json', ignoreIllegals: true })\n : '';\n return `${name}\\n${configLabel}\\n${configObj}`;\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":";;;;;;AAA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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;MACbkB,IAAI,EAAEvC,MAAM,CAACuC,IAAI;MACjBL,MAAM,EAAElC,MAAM,CAACwC,aAAa,GAAGxC,MAAM,CAACwC,aAAa,CAAC,CAAC,GAAGlB,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;AAACW,OAAA,CAAApD,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@1.0.209/dist/linter.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@1.0.209/dist/linter.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@1.0.210/dist/linter.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_linter@1.0.210/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.209",
3
+ "version": "1.0.210",
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.209"
9
+ "version": "1.0.210"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -15,11 +15,11 @@
15
15
  "cli-highlight": "2.1.9",
16
16
  "@teambit/harmony": "0.4.6",
17
17
  "@teambit/cli": "0.0.858",
18
- "@teambit/component": "1.0.209",
19
- "@teambit/envs": "1.0.209",
20
- "@teambit/workspace": "1.0.209",
21
- "@teambit/builder": "1.0.209",
22
- "@teambit/isolator": "1.0.209",
18
+ "@teambit/component": "1.0.210",
19
+ "@teambit/envs": "1.0.210",
20
+ "@teambit/workspace": "1.0.210",
21
+ "@teambit/builder": "1.0.210",
22
+ "@teambit/isolator": "1.0.210",
23
23
  "@teambit/logger": "0.0.951"
24
24
  },
25
25
  "devDependencies": {