• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

protofire / solhint / #1034

24 Jan 2020 03:41PM UTC coverage: 96.267%. Remained the same
#1034

push

fvictorio
Keep spaces intact when fixing 'avoid-throw'

361 of 435 branches covered (82.99%)

0 of 1 new or added line in 1 file covered. (0.0%)

1934 of 2009 relevant lines covered (96.27%)

39.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lib/rules/security/avoid-throw.js
1
const BaseChecker = require('./../base-checker')
1✔
2

3
const ruleId = 'avoid-throw'
1✔
4
const meta = {
1✔
5
  type: 'security',
6

7
  docs: {
8
    description: `"throw" is deprecated, avoid to use it.`,
9
    category: 'Security Rules'
10
  },
11

12
  isDefault: false,
13
  recommended: true,
14
  defaultSetup: 'warn',
15
  fixable: true,
16

17
  schema: []
18
}
19

20
class AvoidThrowChecker extends BaseChecker {
21
  constructor(reporter) {
22
    super(reporter, ruleId, meta)
151✔
23
  }
24

25
  ThrowStatement(node) {
26
    this.error(node, '"throw" is deprecated, avoid to use it', fixer =>
1✔
27
      // we don't use just `node.range` because ThrowStatement includes the semicolon and the spaces before it
28
      // we know that node.range[0] is the 't' of throw
29
      // we're also pretty sure that 'throw' has 5 letters
NEW
30
      fixer.replaceTextRange([node.range[0], node.range[0] + 5], 'revert()')
×
31
    )
32
  }
33
}
34

35
module.exports = AvoidThrowChecker
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc