@teambit/eslint 0.0.1045 → 0.0.1047
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 -1
- package/dist/eslint-config-writer.js +8 -2
- package/dist/eslint-config-writer.js.map +1 -1
- package/dist/{preview-1682911859633.js → preview-1683084947241.js} +2 -2
- package/package-tar/teambit-eslint-0.0.1047.tgz +0 -0
- package/package.json +10 -10
- package/package-tar/teambit-eslint-0.0.1045.tgz +0 -0
|
@@ -9,8 +9,9 @@ export declare class EslintConfigWriter implements ConfigWriterEntry {
|
|
|
9
9
|
cliName: string;
|
|
10
10
|
constructor(linter: LinterMain, logger: Logger);
|
|
11
11
|
patterns: string[];
|
|
12
|
-
calcConfigFiles(executionContext: ExecutionContext): ConfigFile[] | undefined;
|
|
12
|
+
calcConfigFiles(executionContext: ExecutionContext, _env: any, configsRootDir: string): ConfigFile[] | undefined;
|
|
13
13
|
postProcessConfigFiles(writtenConfigFiles: WrittenConfigFile[], executionContext: ExecutionContext, envMapValue: EnvMapValue): Promise<void>;
|
|
14
|
+
private postProcessTSConfig;
|
|
14
15
|
generateExtendingFile(args: GenerateExtendingConfigFilesArgs): ExtendingConfigFile | undefined;
|
|
15
16
|
isBitGenerated(filePath: string): boolean;
|
|
16
17
|
}
|
|
@@ -50,7 +50,7 @@ class EslintConfigWriter {
|
|
|
50
50
|
(0, _defineProperty2().default)(this, "cliName", 'eslint');
|
|
51
51
|
(0, _defineProperty2().default)(this, "patterns", ['**/.eslintrc.json']);
|
|
52
52
|
}
|
|
53
|
-
calcConfigFiles(executionContext) {
|
|
53
|
+
calcConfigFiles(executionContext, _env, configsRootDir) {
|
|
54
54
|
var _linter$generateIdeCo;
|
|
55
55
|
const linter = this.linter.getLinter(executionContext, {});
|
|
56
56
|
if (!linter) return undefined;
|
|
@@ -67,16 +67,22 @@ class EslintConfigWriter {
|
|
|
67
67
|
const tsConfigContent = JSON.stringify(config.tsconfig, null, 2);
|
|
68
68
|
const tsConfigHash = (0, _utils().sha1)(tsConfigContent);
|
|
69
69
|
const tsConfigName = `tsconfig.bit.eslint.${tsConfigHash}.json`;
|
|
70
|
+
const tsConfigFullPath = `${configsRootDir}/${tsConfigName}`;
|
|
70
71
|
const tsConfigFile = {
|
|
71
72
|
content: tsConfigContent,
|
|
72
73
|
hash: tsConfigHash,
|
|
73
74
|
name: tsConfigName
|
|
74
75
|
};
|
|
75
|
-
|
|
76
|
+
// This must use abs path, as otherwise eslint will not find the tsconfig file
|
|
77
|
+
// because it will search for it relative to the workspace root
|
|
78
|
+
(0, _lodash().set)(config.eslintConfig, 'parserOptions.project', tsConfigFullPath);
|
|
76
79
|
eslintConfigFile.content = JSON.stringify(config.eslintConfig, null, 2);
|
|
77
80
|
return [eslintConfigFile, tsConfigFile];
|
|
78
81
|
}
|
|
79
82
|
async postProcessConfigFiles(writtenConfigFiles, executionContext, envMapValue) {
|
|
83
|
+
await this.postProcessTSConfig(writtenConfigFiles, executionContext, envMapValue);
|
|
84
|
+
}
|
|
85
|
+
async postProcessTSConfig(writtenConfigFiles, executionContext, envMapValue) {
|
|
80
86
|
const tsConfigFile = writtenConfigFiles.find(file => file.name.includes('tsconfig.bit.eslint'));
|
|
81
87
|
if (!tsConfigFile) return Promise.resolve();
|
|
82
88
|
const tsConfigPath = tsConfigFile.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","GLOBAL_TYPES_DIR","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 { GLOBAL_TYPES_DIR, 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',
|
|
1
|
+
{"version":3,"names":["BIT_GENERATED_ESLINT_CONFIG_COMMENT","EslintConfigWriter","constructor","linter","logger","calcConfigFiles","executionContext","_env","configsRootDir","getLinter","undefined","id","toLowerCase","includes","config","generateIdeConfig","eslintConfig","eslintConfigFile","content","JSON","stringify","name","tsconfig","tsConfigContent","tsConfigHash","sha1","tsConfigName","tsConfigFullPath","tsConfigFile","hash","set","postProcessConfigFiles","writtenConfigFiles","envMapValue","postProcessTSConfig","find","file","Promise","resolve","tsConfigPath","filePath","exists","fs","pathExists","warn","tsConfig","readJson","compDirs","paths","newTsConfig","expandIncludeExclude","GLOBAL_TYPES_DIR","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 { GLOBAL_TYPES_DIR, 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, _env, configsRootDir: string): 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 tsConfigFullPath = `${configsRootDir}/${tsConfigName}`;\n const tsConfigFile = {\n content: tsConfigContent,\n hash: tsConfigHash,\n name: tsConfigName,\n };\n // This must use abs path, as otherwise eslint will not find the tsconfig file\n // because it will search for it relative to the workspace root\n set(config.eslintConfig, 'parserOptions.project', tsConfigFullPath);\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 await this.postProcessTSConfig(writtenConfigFiles, executionContext, envMapValue);\n }\n\n private async postProcessTSConfig(\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, GLOBAL_TYPES_DIR);\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,EAAEC,IAAI,EAAEC,cAAsB,EAA4B;IAAA;IAC1G,MAAML,MAAM,GAAG,IAAI,CAACA,MAAM,CAACM,SAAS,CAACH,gBAAgB,EAAE,CAAC,CAAC,CAA0B;IACnF,IAAI,CAACH,MAAM,EAAE,OAAOO,SAAS;IAC7B,IAAI,CAACP,MAAM,CAACQ,EAAE,CAACC,WAAW,EAAE,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAOH,SAAS;IACjE,MAAMI,MAAM,4BAAGX,MAAM,CAACY,iBAAiB,0DAAxB,2BAAAZ,MAAM,CAAsB;IAC3C,IAAI,CAACW,MAAM,IAAI,CAACA,MAAM,CAACE,YAAY,EAAE,OAAON,SAAS;I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,gBAAgB;MAAEyC,WAAW,EAAE;IAAM,CAAC;EACnG;EAEAC,cAAc,CAACnB,QAAgB,EAAW;IACxC,MAAMtB,OAAO,GAAGwB,kBAAE,CAACkB,YAAY,CAACpB,QAAQ,CAAC,CAACqB,QAAQ,EAAE;IACpD,OAAO3C,OAAO,CAACL,QAAQ,CAACb,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.1047/dist/eslint.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.defender_eslint@0.0.1047/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.
|
|
3
|
+
"version": "0.0.1047",
|
|
4
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.1047"
|
|
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.1047",
|
|
21
|
+
"@teambit/linter": "0.0.1047",
|
|
22
|
+
"@teambit/logger": "0.0.798",
|
|
23
|
+
"@teambit/typescript": "0.0.1047",
|
|
24
|
+
"@teambit/workspace-config-files": "0.0.27",
|
|
25
|
+
"@teambit/component": "0.0.1047",
|
|
26
|
+
"@teambit/cli": "0.0.705",
|
|
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.484",
|
|
42
42
|
"react": "^16.8.0 || ^17.0.0",
|
|
43
43
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
44
44
|
},
|
|
Binary file
|