In zepto.js :
window.$ === undefined && (window.$ = Zepto);
I'm using vscode + eslint + eslint-config-airbnb-base@latest, then show
[eslint] Expected an assignment or function call and instead saw an expression. (no-unused-expressions)
and I change .eslintrc:
"extends": "standard",
the warning disappeared.
Is this a bug or improper grammar ?
Alright, I found this:
packages/eslint-config-airbnb-base/rules/best-practices.js
// disallow usage of expressions in statement position
'no-unused-expressions': ['error', {
allowShortCircuit: false,
allowTernary: false,
allowTaggedTemplates: false,
}],
And this :
eslint-config-standard/eslintrc.json
no-unused-expressions": ["error", {
"allowShortCircuit": true,
"allowTernary": true,
"allowTaggedTemplates": true
}],
but I don't know which is better, in this circumstance ?
change it to if..else.. statement ?
The issue is that you鈥檙e abusing value selection operators for control flow (and also conflating assignment with expressions). Use an if.
The issue is that you鈥檙e abusing value selection operators for control flow (and also conflating assignment with expressions). Use an
if.
Hi, could you elaborate why using value selection operators in this case is a bad practice? Just personally interested in the topic.
@fleksin because their purpose is to select a value. Using them for control flow is using them for something other than their intended purpose - abusing them.
Most helpful comment
The issue is that you鈥檙e abusing value selection operators for control flow (and also conflating assignment with expressions). Use an
if.