GeezerVison is showing github.com — fix: lint&fix auto generated types.ts · bulldba/lowcode-engine@7dde970
File tree
Expand file treeCollapse file tree
Open diff view settings
modules/material-parser/scripts
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: modules/material-parser/scripts/transform.js +10-2Lines changed: 10 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,8 +3,10 @@ const fs = require('fs'); |
3 | 3 | const path = require('path'); |
4 | 4 | const Ajv = require('ajv'); |
5 | 5 | const { compile } = require('json-schema-to-typescript'); |
| 6 | +const { ESLint } = require('eslint'); |
6 | 7 |
|
7 | 8 | const ajv = new Ajv(); |
| 9 | +const eslint = new ESLint({ fix: true }); |
8 | 10 |
|
9 | 11 | const YamlPath = path.resolve(__dirname, '../schemas/schema.yml'); |
10 | 12 | const JsonPath = path.resolve(__dirname, '../src/validate/schema.json'); |
@@ -19,9 +21,15 @@ const tsPath = path.resolve(__dirname, '../src/core/schema/types.ts'); |
19 | 21 | console.log('yaml file is successfully transformed into json'); |
20 | 22 | const ts = await compile(schema, 'ComponentMeta'); |
21 | 23 | fs.writeFileSync(tsPath, ts); |
22 | | - console.log('schema.d.ts is successfully generated'); |
| 24 | + // Lint files. This doesn't modify target files. |
| 25 | + const results = await eslint.lintFiles([tsPath]); |
| 26 | + |
| 27 | + // Modify the files with the fixed code. |
| 28 | + await ESLint.outputFixes(results); |
| 29 | + |
| 30 | + console.log('schema/types.d.ts is successfully generated'); |
23 | 31 | } catch (e) { |
24 | 32 | console.log(e); |
25 | 33 | process.exit(1); |
26 | 34 | } |
27 | | -})(); |
| 35 | +})(); |