diff --git a/.eslintrc.js b/.eslintrc.js index 1ec3834e6..eba1bac04 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,6 @@ module.exports = { 'no-prototype-builtins': 1, 'no-useless-constructor': 1, 'no-empty-function': 1, - '@typescript-eslint/member-ordering': 0, 'lines-between-class-members': 0, 'no-await-in-loop': 0, 'no-plusplus': 0, @@ -35,22 +34,23 @@ module.exports = { '@typescript-eslint/indent': 0, 'import/no-cycle': 0, '@typescript-eslint/no-shadow': 0, - "@typescript-eslint/method-signature-style": 0, - "@typescript-eslint/consistent-type-assertions": 0, - "@typescript-eslint/no-useless-constructor": 0, + '@typescript-eslint/method-signature-style': 0, + '@typescript-eslint/consistent-type-assertions': 0, + '@typescript-eslint/no-useless-constructor': 0, '@typescript-eslint/dot-notation': 0, // for lint performance '@typescript-eslint/restrict-plus-operands': 0, // for lint performance 'no-unexpected-multiline': 1, - 'no-multiple-empty-lines': ['error', { "max": 1 }], + 'no-multiple-empty-lines': ['error', { max: 1 }], 'lines-around-comment': ['error', { - "beforeBlockComment": true, - "afterBlockComment": false, - "afterLineComment": false, - "allowBlockStart": true, + beforeBlockComment: true, + afterBlockComment: false, + afterLineComment: false, + allowBlockStart: true, }], - "@typescript-eslint/member-ordering": [ - "error", - { "default": ["signature", "field", "constructor", "method"] } + 'comma-dangle': ['error', 'always-multiline'], + '@typescript-eslint/member-ordering': [ + 'error', + { default: ['signature', 'field', 'constructor', 'method'] }, ], - } + }, }; \ No newline at end of file diff --git a/modules/code-generator/src/generator/ModuleBuilder.ts b/modules/code-generator/src/generator/ModuleBuilder.ts index 755ca20c6..e172f716e 100644 --- a/modules/code-generator/src/generator/ModuleBuilder.ts +++ b/modules/code-generator/src/generator/ModuleBuilder.ts @@ -62,10 +62,9 @@ export function createModuleBuilder( if (options.postProcessors.length > 0) { files = files.map((file) => { - let { content } = file; - const type = file.ext; + let { content, ext: type, name } = file; options.postProcessors.forEach((processer) => { - content = processer(content, type); + content = processer(content, type, name); }); return createResultFile(file.name, type, content); diff --git a/modules/code-generator/src/types/core.ts b/modules/code-generator/src/types/core.ts index 30c86a7e9..1a85db965 100644 --- a/modules/code-generator/src/types/core.ts +++ b/modules/code-generator/src/types/core.ts @@ -1,20 +1,15 @@ import { - IPublicTypeJSONArray, - IPublicTypeJSONObject, IPublicTypeCompositeArray, - IPublicTypeCompositeObject, - ResultDir, + IPublicTypeCompositeObject, IPublicTypeJSExpression, + IPublicTypeJSFunction, IPublicTypeJSONArray, + IPublicTypeJSONObject, IPublicTypeJSSlot, IPublicTypeNodeDataType, + IPublicTypeProjectSchema, ResultDir, ResultFile, - IPublicTypeNodeDataType, - IPublicTypeProjectSchema, - IPublicTypeJSExpression, - IPublicTypeJSFunction, - IPublicTypeJSSlot, } from '@alilc/lowcode-types'; -import { IParseResult } from './intermediate'; -import { IScopeBindings } from '../utils/ScopeBindings'; import type { ProjectBuilderInitOptions } from '../generator/ProjectBuilder'; +import { IScopeBindings } from '../utils/ScopeBindings'; +import { IParseResult } from './intermediate'; export enum FileType { CSS = 'css', @@ -69,16 +64,16 @@ export interface ICodeStruct extends IBaseCodeStruct { /** 上下文数据,用来在插件之间共享一些数据 */ export interface IContextData extends IProjectBuilderOptions { - /** - * 是否使用了 Ref 的 API (this.$/this.$$) - * */ - useRefApi?: boolean; - /** * 其他自定义数据 * (三方自定义插件也可以在此放一些数据,建议起个长一点的名称,用自己的插件名做前缀,以防冲突) */ [key: string]: any; + + /** + * 是否使用了 Ref 的 API (this.$/this.$$) + * */ + useRefApi?: boolean; } export type BuilderComponentPlugin = (initStruct: ICodeStruct) => Promise; @@ -202,7 +197,7 @@ export type ProjectPostProcessor = ( export type PostProcessorFactory = (config?: T) => PostProcessor; /** 模块级别的后置处理器 */ -export type PostProcessor = (content: string, fileType: string) => string; +export type PostProcessor = (content: string, fileType: string, name: string) => string; // TODO: temp interface, need modify export interface IPluginOptions {