Repository: protofire/solhint (js)

Issue:
`compiler-version` should ignore `pragma experimental` statements
File:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;
pragma experimental ABIEncoderV2;

contract Main {
}
```

Config:

```
{
  rules: { 'compiler-version': ['error', '^0.7.4'] }
}
```

This throws an error in the second pragma, which is obviously wrong. The fix is probably to check here:

https://github.com/protofire/solhint/blob/15a964c9466276f297d9b1e9d1a88f0b3eae7be5/lib/rules/security/compiler-version.js#L50

that `node.name === "version"`

Pull request description:
Check name of pragma for compiler-rule
Closes #290 

Patch:
diff --git a/lib/rules/security/compiler-version.js b/lib/rules/security/compiler-version.js
index 89895c2..46631d4 100644
--- a/lib/rules/security/compiler-version.js
+++ b/lib/rules/security/compiler-version.js
@@ -48,7 +48,10 @@ class CompilerVersionChecker extends BaseChecker {
   }
 
   PragmaDirective(node) {
-    if (!semver.satisfies(semver.minVersion(node.value), this.requirement)) {
+    if (
+      node.name === 'solidity' &&
+      !semver.satisfies(semver.minVersion(node.value), this.requirement)
+    ) {
       this.warn(
         node,
         `Compiler version ${node.value} does not satisfy the ${this.requirement} semver requirement`


Test patch:
diff --git a/test/rules/security/compiler-version.js b/test/rules/security/compiler-version.js
index e69b115..3153006 100644
--- a/test/rules/security/compiler-version.js
+++ b/test/rules/security/compiler-version.js
@@ -187,4 +187,19 @@ describe('Linter - compiler-version', () => {
 
     assert.equal(report.errorCount, 0)
   })
+
+  it(`should not report compiler version error with correct pragma and pragma experimental`, () => {
+    const report = linter.processStr(
+      `pragma solidity ^0.7.4;
+       pragma experimental ABIEncoderV2;
+       
+       contract Main {
+       }`,
+      {
+        rules: { 'compiler-version': ['error', '^0.7.4'] }
+      }
+    )
+
+    assert.equal(report.errorCount, 0)
+  })
 })