Skip to content

Commit 7dde970

Browse files
committed
fix: lint&fix auto generated types.ts
1 parent f624bc9 commit 7dde970

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

modules/material-parser/scripts/transform.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ const fs = require('fs');
33
const path = require('path');
44
const Ajv = require('ajv');
55
const { compile } = require('json-schema-to-typescript');
6+
const { ESLint } = require('eslint');
67

78
const ajv = new Ajv();
9+
const eslint = new ESLint({ fix: true });
810

911
const YamlPath = path.resolve(__dirname, '../schemas/schema.yml');
1012
const JsonPath = path.resolve(__dirname, '../src/validate/schema.json');
@@ -19,9 +21,15 @@ const tsPath = path.resolve(__dirname, '../src/core/schema/types.ts');
1921
console.log('yaml file is successfully transformed into json');
2022
const ts = await compile(schema, 'ComponentMeta');
2123
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');
2331
} catch (e) {
2432
console.log(e);
2533
process.exit(1);
2634
}
27-
})();
35+
})();

0 commit comments

Comments
 (0)