Check for conflict when linting jison

This commit is contained in:
Sidharth Vinod 2023-04-24 00:15:51 +05:30
parent d09151e870
commit d125d22488
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD

View File

@ -14,12 +14,17 @@ const lint = async (file: string): Promise<boolean> => {
console.log(`Linting ${file}`); console.log(`Linting ${file}`);
const jisonCode = await readFile(file, 'utf8'); const jisonCode = await readFile(file, 'utf8');
// @ts-ignore no typings // @ts-ignore no typings
const jsCode = new jison.Generator(jisonCode, { moduleType: 'amd' }).generate(); const generator = new jison.Generator(jisonCode, { moduleType: 'amd' });
const jsCode = generator.generate();
const [result] = await linter.lintText(jsCode); const [result] = await linter.lintText(jsCode);
if (result.errorCount > 0) { if (result.errorCount > 0) {
console.error(`Linting failed for ${file}`); console.error(`Linting failed for ${file}`);
console.error(result.messages); console.error(result.messages);
} }
if (generator.conflicts > 0) {
console.error(`Linting failed for ${file}. Conflicts found in grammar`);
return false;
}
return result.errorCount === 0; return result.errorCount === 0;
}; };