diff --git a/README.md b/README.md index b5a12a4d..507c31e8 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ Commands: stdin [options] linting of source code data provided to STDIN ``` ### Note -`--fix` option currently works only on "avoid-throw" and "avoid-sha3" rules - +The `--fix` option currently works only on "avoid-throw" and "avoid-sha3" rules +

## Configuration You can use a `.solhint.json` file to configure Solhint for the whole project. @@ -88,6 +88,10 @@ This file has the following format: "extends": "solhint:default" } ``` +### Note +The `solhint:default` configuration contains only two rules: max-line-length & no-console +

+ ### Sample ```json diff --git a/docs/rules.md b/docs/rules.md index 65aacdf3..4868aab8 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -15,6 +15,7 @@ title: "Rule Index of Solhint" | [no-console](./rules/best-practises/no-console.md) | No console.log/logInt/logBytesX/logString/etc & No hardhat and forge-std console.sol import statements | ✔️ | | [no-empty-blocks](./rules/best-practises/no-empty-blocks.md) | Code contains empty block. | ✔️ | | [no-global-import](./rules/best-practises/no-global-import.md) | Import statement includes an entire file instead of selected symbols | ✔️ | +| [no-unused-import](./rules/best-practises/no-unused-import.md) | Imported name is not used | ✔️ | | [no-unused-vars](./rules/best-practises/no-unused-vars.md) | Variable "name" is unused. | ✔️ | | [payable-fallback](./rules/best-practises/payable-fallback.md) | When fallback is not payable you will not be able to receive ethers. | ✔️ | | [reason-string](./rules/best-practises/reason-string.md) | Require or revert statement must have a reason string and check that each reason string is at most N characters long. | ✔️ | @@ -26,13 +27,13 @@ title: "Rule Index of Solhint" | Rule Id | Error | Recommended | | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------- | | [comprehensive-interface](./rules/miscellaneous/comprehensive-interface.md) | Check that all public or external functions are override. This is iseful to make sure that the whole API is extracted in an interface. | | +| [quotes](./rules/miscellaneous/quotes.md) | Use double quotes for string literals. Values must be 'single' or 'double'. | ✔️ | ## Style Guide Rules | Rule Id | Error | Recommended | | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ----------- | -| [quotes](./rules/miscellaneous/quotes.md) | Use double quotes for string literals. Values must be 'single' or 'double'. | ✔️ | | [const-name-snakecase](./rules/naming/const-name-snakecase.md) | Constant name must be in capitalized SNAKE_CASE. | ✔️ | | [contract-name-camelcase](./rules/naming/contract-name-camelcase.md) | Contract name must be in CamelCase. | ✔️ | | [event-name-camelcase](./rules/naming/event-name-camelcase.md) | Event name must be in CamelCase. | ✔️ | diff --git a/docs/rules/best-practises/no-unused-import.md b/docs/rules/best-practises/no-unused-import.md new file mode 100644 index 00000000..e03199a1 --- /dev/null +++ b/docs/rules/best-practises/no-unused-import.md @@ -0,0 +1,39 @@ +--- +warning: "This is a dynamically generated file. Do not edit manually." +layout: "default" +title: "no-unused-import | Solhint" +--- + +# no-unused-import +![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) +![Category Badge](https://img.shields.io/badge/-Best%20Practise%20Rules-informational) +![Default Severity Badge warn](https://img.shields.io/badge/Default%20Severity-warn-yellow) +> The {"extends": "solhint:recommended"} property in a configuration file enables this rule. + + +## Description +Imported name is not used + +## Options +This rule accepts a string option of rule severity. Must be one of "error", "warn", "off". Default to warn. + +### Example Config +```json +{ + "rules": { + "no-unused-import": "warn" + } +} +``` + + +## Examples +This rule does not have examples. + +## Version +This rule is introduced in the latest version. + +## Resources +- [Rule source](https://github.com/protofire/solhint/tree/master/lib/rules/best-practises/no-unused-import.js) +- [Document source](https://github.com/protofire/solhint/tree/master/docs/rules/best-practises/no-unused-import.md) +- [Test cases](https://github.com/protofire/solhint/tree/master/test/rules/best-practises/no-unused-import.js) diff --git a/docs/rules/miscellaneous/quotes.md b/docs/rules/miscellaneous/quotes.md index 94cfb3d4..e260f159 100644 --- a/docs/rules/miscellaneous/quotes.md +++ b/docs/rules/miscellaneous/quotes.md @@ -6,7 +6,7 @@ title: "quotes | Solhint" # quotes ![Recommended Badge](https://img.shields.io/badge/-Recommended-brightgreen) -![Category Badge](https://img.shields.io/badge/-Style%20Guide%20Rules-informational) +![Category Badge](https://img.shields.io/badge/-Miscellaneous-informational) ![Default Severity Badge error](https://img.shields.io/badge/Default%20Severity-error-red) > The {"extends": "solhint:recommended"} property in a configuration file enables this rule. diff --git a/lib/rules/miscellaneous/quotes.js b/lib/rules/miscellaneous/quotes.js index b53b2bad..4212ea38 100644 --- a/lib/rules/miscellaneous/quotes.js +++ b/lib/rules/miscellaneous/quotes.js @@ -10,7 +10,7 @@ const meta = { docs: { description: `Use double quotes for string literals. Values must be 'single' or 'double'.`, - category: 'Style Guide Rules', + category: 'Miscellaneous', options: [ { description: severityDescription,