@teambit/eslint 0.0.1026 → 0.0.1027
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/eslint-config-writer.d.ts +2 -2
- package/dist/eslint-config-writer.js +8 -3
- package/dist/eslint-config-writer.js.map +1 -1
- package/dist/{preview-1680146722705.js → preview-1680233251421.js} +2 -2
- package/package-tar/teambit-eslint-0.0.1027.tgz +0 -0
- package/package.json +11 -11
- package/package-tar/teambit-eslint-0.0.1026.tgz +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutionContext } from '@teambit/envs';
|
|
2
|
-
import type { ConfigWriterEntry, EnvMapValue, WrittenConfigFile, ExtendingConfigFile, ConfigFile } from '@teambit/workspace-config-files';
|
|
2
|
+
import type { ConfigWriterEntry, EnvMapValue, WrittenConfigFile, ExtendingConfigFile, ConfigFile, GenerateExtendingConfigFilesArgs } from '@teambit/workspace-config-files';
|
|
3
3
|
import { Logger } from '@teambit/logger';
|
|
4
4
|
import { LinterMain } from '@teambit/linter';
|
|
5
5
|
export declare class EslintConfigWriter implements ConfigWriterEntry {
|
|
@@ -11,6 +11,6 @@ export declare class EslintConfigWriter implements ConfigWriterEntry {
|
|
|
11
11
|
patterns: string[];
|
|
12
12
|
calcConfigFiles(executionContext: ExecutionContext): ConfigFile[] | undefined;
|
|
13
13
|
postProcessConfigFiles(writtenConfigFiles: WrittenConfigFile[], executionContext: ExecutionContext, envMapValue: EnvMapValue): Promise<void>;
|
|
14
|
-
generateExtendingFile(
|
|
14
|
+
generateExtendingFile(args: GenerateExtendingConfigFilesArgs): ExtendingConfigFile | undefined;
|
|
15
15
|
isBitGenerated(filePath: string): boolean;
|
|
16
16
|
}
|
|
@@ -93,17 +93,22 @@ class EslintConfigWriter {
|
|
|
93
93
|
});
|
|
94
94
|
return Promise.resolve();
|
|
95
95
|
}
|
|
96
|
-
generateExtendingFile(
|
|
96
|
+
generateExtendingFile(args) {
|
|
97
|
+
const {
|
|
98
|
+
writtenConfigFiles
|
|
99
|
+
} = args;
|
|
97
100
|
const eslintConfigFile = writtenConfigFiles.find(file => file.name.includes('.eslintrc.bit'));
|
|
98
101
|
if (!eslintConfigFile) return undefined;
|
|
99
102
|
const config = {
|
|
100
|
-
|
|
103
|
+
// Using DSL to make sure it will be replaced with relative path
|
|
104
|
+
extends: [`{${eslintConfigFile.name}}`]
|
|
101
105
|
};
|
|
102
106
|
const content = `${BIT_GENERATED_ESLINT_CONFIG_COMMENT}\n${JSON.stringify(config, null, 2)}`;
|
|
103
107
|
return {
|
|
104
108
|
content,
|
|
105
109
|
name: '.eslintrc.json',
|
|
106
|
-
extendingTarget: eslintConfigFile
|
|
110
|
+
extendingTarget: eslintConfigFile,
|
|
111
|
+
useAbsPaths: false
|
|
107
112
|
};
|
|
108
113
|
}
|
|
109
114
|
isBitGenerated(filePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BIT_GENERATED_ESLINT_CONFIG_COMMENT","EslintConfigWriter","constructor","linter","logger","calcConfigFiles","executionContext","getLinter","undefined","id","toLowerCase","includes","config","generateIdeConfig","eslintConfig","eslintConfigFile","content","JSON","stringify","name","tsconfig","tsConfigContent","tsConfigHash","sha1","tsConfigName","tsConfigFile","hash","set","postProcessConfigFiles","writtenConfigFiles","envMapValue","find","file","Promise","resolve","tsConfigPath","filePath","exists","fs","pathExists","warn","tsConfig","readJson","compDirs","paths","newTsConfig","expandIncludeExclude","outputJSONSync","spaces","generateExtendingFile","extends","extendingTarget","isBitGenerated","readFileSync","toString"],"sources":["eslint-config-writer.ts"],"sourcesContent":["import { sha1 } from '@teambit/legacy/dist/utils';\nimport fs from 'fs-extra';\nimport { ExecutionContext } from '@teambit/envs';\nimport type {\n ConfigWriterEntry,\n EnvMapValue,\n WrittenConfigFile,\n ExtendingConfigFile,\n ConfigFile,\n} from '@teambit/workspace-config-files';\nimport { expandIncludeExclude } from '@teambit/typescript';\nimport { set } from 'lodash';\nimport { Logger } from '@teambit/logger';\nimport { LinterMain } from '@teambit/linter';\nimport { EslintLinterInterface } from './eslint-linter-interface';\n\nconst BIT_GENERATED_ESLINT_CONFIG_COMMENT = '// bit-generated-eslint-config';\n\nexport class EslintConfigWriter implements ConfigWriterEntry {\n name = 'EslintConfigWriter';\n cliName = 'eslint';\n\n constructor(private linter: LinterMain, private logger: Logger) {}\n patterns: string[] = ['**/.eslintrc.json'];\n\n calcConfigFiles(executionContext: ExecutionContext): ConfigFile[] | undefined {\n const linter = this.linter.getLinter(executionContext, {}) as EslintLinterInterface;\n if (!linter) return undefined;\n if (!linter.id.toLowerCase().includes('eslint')) return undefined;\n const config = linter.generateIdeConfig?.();\n if (!config || !config.eslintConfig) return undefined;\n const eslintConfigFile = {\n content: JSON.stringify(config.eslintConfig, null, 2),\n name: '.eslintrc.bit.{hash}.json',\n };\n if (!config.tsconfig) {\n return [eslintConfigFile];\n }\n const tsConfigContent = JSON.stringify(config.tsconfig, null, 2);\n const tsConfigHash = sha1(tsConfigContent);\n const tsConfigName = `tsconfig.bit.eslint.${tsConfigHash}.json`;\n const tsConfigFile = {\n content: tsConfigContent,\n hash: tsConfigHash,\n name: tsConfigName,\n };\n set(config.eslintConfig, 'parserOptions.project', tsConfigName);\n eslintConfigFile.content = JSON.stringify(config.eslintConfig, null, 2);\n return [eslintConfigFile, tsConfigFile];\n }\n\n async postProcessConfigFiles(\n writtenConfigFiles: WrittenConfigFile[],\n executionContext: ExecutionContext,\n envMapValue: EnvMapValue\n ): Promise<void> {\n const tsConfigFile = writtenConfigFiles.find((file) => file.name.includes('tsconfig.bit.eslint'));\n if (!tsConfigFile) return Promise.resolve();\n const tsConfigPath = tsConfigFile.filePath;\n const exists = await fs.pathExists(tsConfigPath);\n if (!exists) {\n this.logger.warn(\n `EslintConfigWriter, tsconfig file ${tsConfigPath} was not found for post process. if it is part of --dry-run, it is ok.`\n );\n return Promise.resolve();\n }\n const tsConfig = await fs.readJson(tsConfigPath);\n const compDirs: string[] = envMapValue.paths;\n const newTsConfig = expandIncludeExclude(tsConfigPath, tsConfig, compDirs);\n\n fs.outputJSONSync(tsConfigPath, newTsConfig, { spaces: 2 });\n return Promise.resolve();\n }\n\n generateExtendingFile(
|
|
1
|
+
{"version":3,"names":["BIT_GENERATED_ESLINT_CONFIG_COMMENT","EslintConfigWriter","constructor","linter","logger","calcConfigFiles","executionContext","getLinter","undefined","id","toLowerCase","includes","config","generateIdeConfig","eslintConfig","eslintConfigFile","content","JSON","stringify","name","tsconfig","tsConfigContent","tsConfigHash","sha1","tsConfigName","tsConfigFile","hash","set","postProcessConfigFiles","writtenConfigFiles","envMapValue","find","file","Promise","resolve","tsConfigPath","filePath","exists","fs","pathExists","warn","tsConfig","readJson","compDirs","paths","newTsConfig","expandIncludeExclude","outputJSONSync","spaces","generateExtendingFile","args","extends","extendingTarget","useAbsPaths","isBitGenerated","readFileSync","toString"],"sources":["eslint-config-writer.ts"],"sourcesContent":["import { sha1 } from '@teambit/legacy/dist/utils';\nimport fs from 'fs-extra';\nimport { ExecutionContext } from '@teambit/envs';\nimport type {\n ConfigWriterEntry,\n EnvMapValue,\n WrittenConfigFile,\n ExtendingConfigFile,\n ConfigFile,\n GenerateExtendingConfigFilesArgs,\n} from '@teambit/workspace-config-files';\nimport { expandIncludeExclude } from '@teambit/typescript';\nimport { set } from 'lodash';\nimport { Logger } from '@teambit/logger';\nimport { LinterMain } from '@teambit/linter';\nimport { EslintLinterInterface } from './eslint-linter-interface';\n\nconst BIT_GENERATED_ESLINT_CONFIG_COMMENT = '// bit-generated-eslint-config';\n\nexport class EslintConfigWriter implements ConfigWriterEntry {\n name = 'EslintConfigWriter';\n cliName = 'eslint';\n\n constructor(private linter: LinterMain, private logger: Logger) {}\n patterns: string[] = ['**/.eslintrc.json'];\n\n calcConfigFiles(executionContext: ExecutionContext): ConfigFile[] | undefined {\n const linter = this.linter.getLinter(executionContext, {}) as EslintLinterInterface;\n if (!linter) return undefined;\n if (!linter.id.toLowerCase().includes('eslint')) return undefined;\n const config = linter.generateIdeConfig?.();\n if (!config || !config.eslintConfig) return undefined;\n const eslintConfigFile = {\n content: JSON.stringify(config.eslintConfig, null, 2),\n name: '.eslintrc.bit.{hash}.json',\n };\n if (!config.tsconfig) {\n return [eslintConfigFile];\n }\n const tsConfigContent = JSON.stringify(config.tsconfig, null, 2);\n const tsConfigHash = sha1(tsConfigContent);\n const tsConfigName = `tsconfig.bit.eslint.${tsConfigHash}.json`;\n const tsConfigFile = {\n content: tsConfigContent,\n hash: tsConfigHash,\n name: tsConfigName,\n };\n set(config.eslintConfig, 'parserOptions.project', tsConfigName);\n eslintConfigFile.content = JSON.stringify(config.eslintConfig, null, 2);\n return [eslintConfigFile, tsConfigFile];\n }\n\n async postProcessConfigFiles(\n writtenConfigFiles: WrittenConfigFile[],\n executionContext: ExecutionContext,\n envMapValue: EnvMapValue\n ): Promise<void> {\n const tsConfigFile = writtenConfigFiles.find((file) => file.name.includes('tsconfig.bit.eslint'));\n if (!tsConfigFile) return Promise.resolve();\n const tsConfigPath = tsConfigFile.filePath;\n const exists = await fs.pathExists(tsConfigPath);\n if (!exists) {\n this.logger.warn(\n `EslintConfigWriter, tsconfig file ${tsConfigPath} was not found for post process. if it is part of --dry-run, it is ok.`\n );\n return Promise.resolve();\n }\n const tsConfig = await fs.readJson(tsConfigPath);\n const compDirs: string[] = envMapValue.paths;\n const newTsConfig = expandIncludeExclude(tsConfigPath, tsConfig, compDirs);\n\n fs.outputJSONSync(tsConfigPath, newTsConfig, { spaces: 2 });\n return Promise.resolve();\n }\n\n generateExtendingFile(args: GenerateExtendingConfigFilesArgs): ExtendingConfigFile | undefined {\n const { writtenConfigFiles } = args;\n const eslintConfigFile = writtenConfigFiles.find((file) => file.name.includes('.eslintrc.bit'));\n if (!eslintConfigFile) return undefined;\n const config = {\n // Using DSL to make sure it will be replaced with relative path\n extends: [`{${eslintConfigFile.name}}`],\n };\n const content = `${BIT_GENERATED_ESLINT_CONFIG_COMMENT}\\n${JSON.stringify(config, null, 2)}`;\n return { content, name: '.eslintrc.json', extendingTarget: eslintConfigFile, useAbsPaths: false };\n }\n\n isBitGenerated(filePath: string): boolean {\n const content = fs.readFileSync(filePath).toString();\n return content.includes(BIT_GENERATED_ESLINT_CONFIG_COMMENT);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAUA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKA,MAAMA,mCAAmC,GAAG,gCAAgC;AAErE,MAAMC,kBAAkB,CAA8B;EAI3DC,WAAW,CAASC,MAAkB,EAAUC,MAAc,EAAE;IAAA,KAA5CD,MAAkB,GAAlBA,MAAkB;IAAA,KAAUC,MAAc,GAAdA,MAAc;IAAA,8CAHvD,oBAAoB;IAAA,iDACjB,QAAQ;IAAA,kDAGG,CAAC,mBAAmB,CAAC;EADuB;EAGjEC,eAAe,CAACC,gBAAkC,EAA4B;IAAA;IAC5E,MAAMH,MAAM,GAAG,IAAI,CAACA,MAAM,CAACI,SAAS,CAACD,gBAAgB,EAAE,CAAC,CAAC,CAA0B;IACnF,IAAI,CAACH,MAAM,EAAE,OAAOK,SAAS;IAC7B,IAAI,CAACL,MAAM,CAACM,EAAE,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAOH,SAAS;IACjE,MAAMI,MAAM,4BAAGT,MAAM,CAACU,iBAAiB,0DAAxB,2BAAAV,MAAM,CAAsB;IAC3C,IAAI,CAACS,MAAM,IAAI,CAACA,MAAM,CAACE,YAAY,EAAE,OAAON,SAAS;IACrD,MAAMO,gBAAgB,GAAG;MACvBC,OAAO,EAAEC,IAAI,CAACC,SAAS,CAACN,MAAM,CAACE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;MACrDK,IAAI,EAAE;IACR,CAAC;IAC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AChD,MAAMQ,QAAkB,GAAGb,WAAW,CAACc,KAAK;IAC5C,MAAMC,WAAW,GAAG,IAAAC,kCAAoB,EAACX,YAAY,EAAEM,QAAQ,EAAEE,QAAQ,CAAC;IAE1EL,kBAAE,CAACS,cAAc,CAACZ,YAAY,EAAEU,WAAW,EAAE;MAAEG,MAAM,EAAE;IAAE,CAAC,CAAC;IAC3D,OAAOf,OAAO,CAACC,OAAO,EAAE;EAC1B;EAEAe,qBAAqB,CAACC,IAAsC,EAAmC;IAC7F,MAAM;MAAErB;IAAmB,CAAC,GAAGqB,IAAI;IACnC,MAAMnC,gBAAgB,GAAGc,kBAAkB,CAACE,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACb,IAAI,CAACR,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC/F,IAAI,CAACI,gBAAgB,EAAE,OAAOP,SAAS;IACvC,MAAMI,MAAM,GAAG;MACb;MACAuC,OAAO,EAAE,CAAE,IAAGpC,gBAAgB,CAACI,IAAK,GAAE;IACxC,CAAC;IACD,MAAMH,OAAO,GAAI,GAAEhB,mCAAoC,KAAIiB,IAAI,CAACC,SAAS,CAACN,MAAM,EAAE,IAAI,EAAE,CAAC,CAAE,EAAC;IAC5F,OAAO;MAAEI,OAAO;MAAEG,IAAI,EAAE,gBAAgB;MAAEiC,eAAe,EAAErC,gBAAgB;MAAEsC,WAAW,EAAE;IAAM,CAAC;EACnG;EAEAC,cAAc,CAAClB,QAAgB,EAAW;IACxC,MAAMpB,OAAO,GAAGsB,kBAAE,CAACiB,YAAY,CAACnB,QAAQ,CAAC,CAACoB,QAAQ,EAAE;IACpD,OAAOxC,OAAO,CAACL,QAAQ,CAACX,mCAAmC,CAAC;EAC9D;AACF;AAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.1027/dist/eslint.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.1027/dist/eslint.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/eslint",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"homepage": "https://bit.
|
|
3
|
+
"version": "0.0.1027",
|
|
4
|
+
"homepage": "https://bit.cloud/teambit/defender/eslint",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.defender",
|
|
8
8
|
"name": "eslint",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.1027"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"fs-extra": "10.0.0",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"core-js": "^3.0.0",
|
|
18
18
|
"@babel/runtime": "7.20.0",
|
|
19
19
|
"@teambit/harmony": "0.4.6",
|
|
20
|
-
"@teambit/envs": "0.0.
|
|
21
|
-
"@teambit/linter": "0.0.
|
|
22
|
-
"@teambit/logger": "0.0.
|
|
23
|
-
"@teambit/typescript": "0.0.
|
|
24
|
-
"@teambit/workspace-config-files": "0.0.
|
|
25
|
-
"@teambit/component": "0.0.
|
|
26
|
-
"@teambit/cli": "0.0.
|
|
20
|
+
"@teambit/envs": "0.0.1027",
|
|
21
|
+
"@teambit/linter": "0.0.1027",
|
|
22
|
+
"@teambit/logger": "0.0.783",
|
|
23
|
+
"@teambit/typescript": "0.0.1027",
|
|
24
|
+
"@teambit/workspace-config-files": "0.0.7",
|
|
25
|
+
"@teambit/component": "0.0.1027",
|
|
26
|
+
"@teambit/cli": "0.0.690",
|
|
27
27
|
"@teambit/defender.eslint.config-mutator": "0.0.92"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@teambit/legacy": "1.0.
|
|
41
|
+
"@teambit/legacy": "1.0.470",
|
|
42
42
|
"react": "^16.8.0 || ^17.0.0",
|
|
43
43
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
44
44
|
},
|
|
Binary file
|