jshint / jshint.github.io

The homepage for JSHint
http://jshint.com
20 stars 19 forks source link

Update docs.md with updated example according to current defaults #58

Closed Black-Platypus closed 2 years ago

Black-Platypus commented 3 years ago

Old example was referring to outdated behavior (as an aside in https://github.com/jshint/jshint/issues/3512 ); I chose a new example and tried to make the purpose and workings of the two kinds of boolean options more clear.

As I understand it, looking at the options.js at https://github.com/jshint/jshint/blob/master/src/options.js , the current default options have curly: true and notypeof: true. if that's not the case, please correct me.

jugglinmike commented 3 years ago

Thanks for following up on this! It's always nice to get a hand :)

I chose a new example and tried to make the purpose and workings of the two kinds of boolean options more clear.

Sounds like a good idea to me

As I understand it, looking at the options.js at https://github.com/jshint/jshint/blob/master/src/options.js , the current default options have curly: true and notypeof: true. if that's not the case, please correct me.

Not quite. Both "enforcing" and "relaxing" options are disabled by default. The values used in the source code aren't related to JSHint's enforcement.

If you input your example code without any configuration, JSHint will report:

line 1, col 15, Invalid typeof value 'fuction' (W122)

If you want to suppress that warning, you'd have to configure JSHint to be less strict by enabling the "relaxing" option, notypeof.

If you want to receive a warning about the absense of curly braces, you'd have to configure JSHint to be more strict by enabling the "enforcing" option, curly.