id-length rule not firing on a ternary
See original GitHub issueWhat version of ESLint are you using?
2.11.1
What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint
Please show your full configuration:
Configuration
---
# Use babel-eslint parser in order to support babel plugins
# necessary to e.g. strip Flowtype annotations
parser: babel-eslint
parserOptions:
ecmaVersion: 6
impliedStrict: true
ecmaFeatures:
arrowFunctions: true
blockBindings: true
classes: true
defaultParams: true
destructuring: true
forOf: true
generators: false
modules: true
objectLiteralComputedProperties: true
objectLiteralDuplicateProperties: false
objectLiteralShorthandMethods: true
objectLiteralShorthandProperties: true
spread: true
superInFunctions: true
templateStrings: true
jsx: true
env:
browser: true
mocha: true
globals:
expect: false
plugins:
- react
extends:
- eslint:recommended
- plugin:react/recommended
rules:
# Babel inserts 'use strict' for us already
strict:
- error
- never
# Best Practices
array-callback-return: error
complexity:
- error
- 5
curly: error
default-case: error
dot-notation: error
eqeqeq: error
no-alert: error
no-div-regex: error
no-empty-function: error
no-eval: error
no-extend-native: error
no-extra-bind: error
no-implicit-coercion: error
no-implicit-globals: error
no-implied-eval: error
no-invalid-this: error
no-labels: error
no-lone-blocks: error
no-loop-func: error
no-multi-spaces: error
no-multi-str: error
no-native-reassign: error
no-new: error
no-new-func: error
no-new-wrappers: error
no-param-reassign:
- error
- props: true
no-return-assign: error
no-script-url: error
no-self-compare: error
no-sequences: error
no-throw-literal: error
no-unmodified-loop-condition: error
no-unused-expressions: error
no-useless-call: error
no-useless-concat: error
no-useless-escape: error
no-void: error
no-warning-comments: warn
no-with: error
wrap-iife: error
yoda: error
# Variables
init-declarations: error
no-shadow:
- error
- hoist: all
no-shadow-restricted-names: error
no-use-before-define: error
# Stylistic
array-bracket-spacing:
- error
- always
brace-style: error
camelcase: error
comma-spacing: error
comma-style: error
computed-property-spacing:
- error
- always
consistent-this: error
eol-last: error
id-length: error
indent:
- error
- 2
- SwitchCase: 1
key-spacing: error
keyword-spacing: error
linebreak-style: error
max-depth:
- error
- 5
max-len:
- error
- 120
max-nested-callbacks:
- error
- 4
max-params:
- error
- 4
max-statements:
- error
- 14
max-statements-per-line: error
new-cap: error
new-parens: error
newline-after-var: error
newline-before-return: error
newline-per-chained-call: error
no-array-constructor: error
no-bitwise: error
no-continue: error
no-inline-comments: error
no-lonely-if: error
no-mixed-spaces-and-tabs: error
no-multiple-empty-lines:
- error
- max: 2
maxEOF: 1
maxBOF: 0
no-negated-condition: error
no-new-object: error
no-plusplus: error
no-restricted-syntax:
- error
- TryStatement
- FunctionDeclaration
no-spaced-func: error
no-trailing-spaces:
- error
- skipBlankLines: true
no-unneeded-ternary: error
no-whitespace-before-property: error
object-curly-spacing:
- error
- always
object-property-newline:
- error
- allowMultiplePropertiesPerLine: true
one-var:
- error
- never
operator-assignment: error
operator-linebreak:
- error
- before
padded-blocks:
- error
- blocks: never
switches: always
classes: always
quote-props:
- error
- as-needed
quotes:
- error
- single
semi:
- error
- never
space-before-blocks: error
space-in-parens:
- error
- never
space-infix-ops:
- error
space-unary-ops: error
spaced-comment: error
unicode-bom: error
# ESerror015
arrow-body-style: error
arrow-parens: error
arrow-spacing: error
no-duplicate-imports: error
no-useless-computed-key: error
no-var: error
object-shorthand: error
prefer-const: error
prefer-spread: error
prefer-template: error
template-curly-spacing:
- error
- always
# React
react/jsx-boolean-value: error
react/jsx-curly-spacing:
- error
- always
react/jsx-equals-spacing: error
react/jsx-handler-names: error
# react/jsx-indent:
# - error
# - 2
react/jsx-indent-props:
- error
- 2
react/jsx-key: error
react/jsx-no-bind: error
react/jsx-no-target-blank: error
react/jsx-pascal-case: error
react/jsx-space-before-closing: error
react/no-multi-comp: error
react/prefer-stateless-function: error
react/prop-types: off
#react/require-optimization: error
react/self-closing-comp: error
react/sort-comp: error
react/wrap-multilines: error
What did you do? Please include the actual source code causing the issue.
Note line 12 of this file, marked with “Issue”:
// @flow
import { RESULTS_ROUTE } from '/routes'
import { fetchDetails, setQuery, setAndFetchQuery } from '/actions'
export const onDetailsEnter = (dispatch) =>
({ params }) => dispatch(fetchDetails(params.id))
export const onLocationChange = (dispatch) =>
(location) => {
const query = location.query.q ? location.query.q : '' // Issue
if (location.pathname === RESULTS_ROUTE) {
dispatch(setAndFetchQuery(query))
} else {
dispatch(setQuery(query))
}
}
What did you expect to happen?
The id-length rule to fire due to the .q
property access.
What actually happened? Please include the actual, raw output from ESLint.
The id-length rule did not fire - there was no output from ESLint, no warnings or errors. This happens in both my editor which runs it on the one file, and when running ESLint from the project level.
If I change that line to instead use a boolean operator like so:
const query = location.query.q || ''
Then the rule does fire.
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (20 by maintainers)
Top Results From Across the Web
Enforce or disallow newlines between operands of ternary ...
This rule enforces or disallows newlines between operands of a ternary expression. Note: The location of the operators is not enforced by this...
Read more >no-ternary - ESLint - Pluggable JavaScript Linter
The ternary operator is used to conditionally assign a value to a variable. Some believe that the use of ternary operators leads to...
Read more >List of available rules - ESLint - Pluggable JavaScript linter
No rules are enabled by default. ... These rules relate to possible syntax or logic errors in JavaScript code: ... disallow nested ternary...
Read more >A Convenient Hybrid Method for Obtaining Liquid–Liquid ...
Liquid–liquid equilibrium data for ternary systems are scarce in ... in a mass balance numerical criterion derived from the lever rule.
Read more >tslint-eslint-rules - npm Package Health Analysis | Snyk
All security vulnerabilities belong to production dependencies of direct and indirect packages. License: MIT. Security Policy: No. We found ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If we are warning on fewer instances, then that’s not a breaking change.
Ah, @nzakas is correct. This would result in fewer error messages so this would be a minor release (“Update”). In that case I think the resolution would be to modify this rule to only check LHS of the assignments/declarations.