hardhat-spdx-silencer
v1.0.1
Published
Make Hardhat shut up the SPDX license identifiers warnings
Readme
hardhat-spdx-silencer
Hardhat plugin to automatically add SPDX license identifiers to Solidity files, preventing compiler warnings about missing license identifiers.
Installation
npm install --save-dev hardhat-spdx-silencer
# or
pnpm add -D hardhat-spdx-silencer
# or
yarn add -D hardhat-spdx-silencerUsage
Add the plugin to your hardhat.config.ts
import { HardhatUserConfig } from 'hardhat/config';
import spdxSilencer from 'hardhat-spdx-silencer';
const config: HardhatUserConfig = {
plugins: [spdxSilencer]
// ... rest of config
};
export default config;That's it! The plugin will automatically add // SPDX-License-Identifier: UNLICENSED to any Solidity file that doesn't already have an SPDX license identifier during compilation.
How It Works
The plugin uses Hardhat's readSourceFile hook to intercept file reads during compilation. When a Solidity file is read:
- If the file doesn't contain an SPDX-License-Identifier (case-insensitive check), it adds
// SPDX-License-Identifier: UNLICENSEDat the beginning of the file - Files that already have an SPDX identifier are left unchanged
- Non-Solidity files are ignored
The identifier is added automatically during normal compilation (npx hardhat compile or npx hardhat build). No special commands or configuration are needed.
Requirements
- Hardhat ^3.0.15
- Node.js (see Hardhat requirements)
License
ISC
Author
0xCryptoMag
