You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Compiler warnings to suppress from build output.
81
-
// Each rule specifies a warning message and the source file it applies to.
82
-
// This allows suppressing known warnings from internal files (e.g., console.sol)
83
-
// while still showing the same warning type from user code.
84
-
exportconstSUPPRESSED_WARNINGS: Array<{
85
-
message: string;
86
-
sourceFile: string;
87
-
}>=[
88
-
{
89
-
message:
90
-
"Natspec memory-safe-assembly special comment for inline assembly is deprecated and scheduled for removal. Use the memory-safe block annotation instead.",
// Compiler warnings to suppress from build output.
4
+
// Supports two types of suppression rules:
5
+
//
6
+
// 1. scope: 'specific-file' - Suppress warnings from specific file paths
7
+
// - Use this to suppress known warnings from internal/library files (e.g., console.sol)
8
+
// - The same warning type will still be shown for user code
9
+
//
10
+
// 2. scope: 'test-files' - Suppress warnings from all test files
11
+
// - Test files are identified as:
12
+
// * Files ending in .t.sol (e.g., Counter.t.sol)
13
+
// * Files inside test/contracts/ directory
14
+
// (e.g., test/contracts/Example.sol)
15
+
// - Use this for warnings that are acceptable in test code but not in production code
16
+
// (e.g., missing SPDX license identifiers or pragma statements)
17
+
exportconstSUPPRESSED_WARNINGS: Array<
18
+
|{
19
+
message: string;
20
+
scope: "specific-file";
21
+
filePath: string;
22
+
}
23
+
|{
24
+
message: string;
25
+
scope: "test-files";
26
+
}
27
+
>=[
28
+
{
29
+
message:
30
+
"Natspec memory-safe-assembly special comment for inline assembly is deprecated and scheduled for removal. Use the memory-safe block annotation instead.",
31
+
scope: "specific-file",
32
+
// Normalize to handle different OS path separators
33
+
filePath: path.normalize("hardhat/console.sol"),
34
+
},
35
+
{
36
+
message: "SPDX license identifier not provided",
37
+
scope: "test-files",
38
+
},
39
+
{
40
+
message: "Source file does not specify required compiler version",
41
+
scope: "test-files",
42
+
},
43
+
];
44
+
45
+
/**
46
+
* Determines if a compiler warning should be suppressed based on the suppression rules.
47
+
*
48
+
* @param errorMessage - The formatted error message from the compiler
49
+
* @param absoluteSolidityTestsPath - Absolute path to the Solidity test directory
50
+
* @param absoluteProjectRoot - Absolute path to the project root
51
+
* @returns true if the warning should be suppressed, false otherwise
52
+
*/
53
+
exportfunctionshouldSuppressWarning(
54
+
errorMessage: string,
55
+
absoluteSolidityTestsPath: string,
56
+
absoluteProjectRoot: string,
57
+
): boolean{
58
+
// Compute relative path from project root to test directory.
0 commit comments