Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Oct 22, 2024
1 parent bda9c4e commit ef9b8c1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scripts/checks/pragma-consistency.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const skip = source => skipPatterns.some(pattern => source.startsWith(pattern));
for (const artifact of artifacts) {
const { output: solcOutput } = require(path.resolve(__dirname, '../..', artifact));

const pragma = {}
const pragma = {};

// Extract pragma directive for all files
for (const source in solcOutput.contracts) {
if (skip(source)) continue;
for (const {literals} of findAll('PragmaDirective', solcOutput.sources[source].ast)) {
for (const { literals } of findAll('PragmaDirective', solcOutput.sources[source].ast)) {
// There should only be one.
pragma[source] = literals.slice(1).join('')
pragma[source] = literals.slice(1).join('');
}
}

Expand All @@ -29,12 +29,14 @@ for (const artifact of artifacts) {
// minimum version of the compiler that matches source's pragma
const minVersion = semver.minVersion(pragma[source]);
// loop over all imports in source
for (const {absolutePath} of findAll('ImportDirective', solcOutput.sources[source].ast)) {
for (const { absolutePath } of findAll('ImportDirective', solcOutput.sources[source].ast)) {
// So files that only import without declaring anything cause issues, because they don't shop in in "pragma"
if (!pragma[absolutePath]) continue;
// Check that the minVersion for source satisfies the requirements of the imported files
if (!semver.satisfies(minVersion, pragma[absolutePath])) {
console.log(`- ${source} uses ${pragma[source]} but depends on ${absolutePath} that requires ${pragma[absolutePath]}`);
console.log(
`- ${source} uses ${pragma[source]} but depends on ${absolutePath} that requires ${pragma[absolutePath]}`,
);
process.exitCode = 1;
}
}
Expand Down

0 comments on commit ef9b8c1

Please sign in to comment.