brenolf / polyjuice

A utility to convert JSHint and JSCS files into ESLint files and vice-versa
MIT License
275 stars 15 forks source link

JSHINT `expr` to ESLINT `no-unused-expressions` #92

Open nyagoking opened 6 years ago

nyagoking commented 6 years ago

Given this JSHINT rule: http://jshint.com/docs/options/#expr

"expr": true

Results in ESLint: https://eslint.org/docs/rules/no-unused-expressions

"no-unused-expressions": 2

Expected ESLint rule:

"no-unused-expressions": 0

Generally, JSHINT Relaxing options suppress warnings when true is specified.

nyagoking commented 6 years ago

The result to which other JSHINT Relaxing options were converted is below. Given this JSHINT rules

"asi": true,
"boss": true,
"debug": true,
"elision": true,
"eqnull": true,
"evil": true,
"globalstrict": true,
"lastsemic": true,
"laxbreak": true,
"laxcomma": true,
"loopfunc": true,
"multistr": true,
"noyield": true,
"plusplus": true,
"proto": true,
"scripturl": true,
"sub": true,
"supernew": true,
"validthis": true,
"withstmt": true

Results in ESLint

"semi": [2, "always"],
"no-cond-assign": [2, "except-parens"],
"no-debugger": 2,
"no-sparse-arrays": 2,
"no-eq-null": 2,
"no-eval": 2,
"strict": [2, "global"],
"linebreak-style": 2,
"comma-style": [2, "last"],
"no-loop-func": 2,
"no-multi-str": 2,
"require-yield": 2,
"no-plusplus": 2,
"no-proto": 2,
"no-script-url": 2,
"dot-notation": 0,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-invalid-this": 2,
"no-with": 2

Expected ESLint rules

"semi": 0,
"no-cond-assign": 0,
"no-debugger": 0,
"no-sparse-arrays": 0,
"no-eq-null": 0,
"no-eval": 0,
"strict": 0,
"linebreak-style": 0,
"comma-style": 0,
"no-loop-func": 0,
"no-multi-str": 0,
"require-yield": 0,
"no-plusplus": 0,
"no-proto": 0,
"no-script-url": 0,
"dot-notation": 0,
"no-new-func": 0,
"no-new-wrappers": 0,
"no-invalid-this": 0,
"no-with": 0

Only option "sub" was correctly converted, but others were not.

nyagoking commented 6 years ago

I found out that several options which suppresses warning are included in JSHINT Enforcing options. Given this JSHINT rules

"funcscope": true,
"iterator": true,
"notypeof": true,
"shadow": true

Results in ESLint

"block-scoped-var": 2,
"no-iterator": 2,
"valid-typeof": 2,
"no-shadow": 0

Expected ESLint rules

"block-scoped-var": 0,
"no-iterator": 0,
"valid-typeof": 0,
"no-shadow": 0

Options except "shadow" were not converted correctly.