Skip to content

Commit

Permalink
make no-unused-imports a recommended rule
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpcapurro committed Mar 9, 2023
1 parent 673bc11 commit 3be5f80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/best-practises/no-unused-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const meta = {
},

isDefault: false,
recommended: false,
recommended: true,
defaultSetup: 'warn',

schema: null,
Expand Down
17 changes: 16 additions & 1 deletion test/rules/best-practises/no-unused-import.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const linter = require('../../../lib/index')
const { assertNoErrors, assertErrorMessage, assertErrorCount } = require('../../common/asserts')
const {
assertNoErrors,
assertErrorMessage,
assertErrorCount,
assertWarnsCount,
} = require('../../common/asserts')

describe('Linter - no-unused-import', () => {
it('should raise when imported name is not used', () => {
Expand All @@ -12,6 +17,16 @@ describe('Linter - no-unused-import', () => {
assertErrorMessage(report, 'imported name A is not used')
})

it('should raise error when using solhint:recommended', () => {
const code = `pragma solidity ^0.5.8; import {A} from "./A.sol";`

const report = linter.processStr(code, {
extends: 'solhint:recommended',
})
assertWarnsCount(report, 1)
assertErrorMessage(report, 'imported name A is not used')
})

it('should report correct name when unused import is aliased', () => {
const code = `import {A as B} from './A.sol';`

Expand Down

0 comments on commit 3be5f80

Please sign in to comment.