bug on prefer destructuring when using with optional chaining
See original GitHub issueTell us about your environment
- ESLint Version: v6.0.1
- Node Version: v12.13.0
- npm Version: 6.13.1
What parser (default, Babel-ESLint, etc.) are you using? @typescript-eslint/parser
Please show your full configuration:
Configuration
module.exports = {
extends: [
'airbnb/base',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:react/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
// 'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 10,
sourceType: 'module',
ecmaFeatures: {
modules: true,
},
},
rules: {
quotes: [2, 'single', { allowTemplateLiterals: true, avoidEscape: true }],
'jsx-quotes': [2, 'prefer-single'],
'react/prop-types': 0,
'no-mixed-operators': 0,
'global-require': 0,
'no-console': 2,
'max-len': [1, 120, 2],
'no-param-reassign': [2, { props: false }],
'no-continue': 0,
'no-underscore-dangle': 0,
'generator-star-spacing': 0,
'no-duplicate-imports': 0,
'no-use-before-define': 0,
'consistent-return': 0,
'spaced-comment': 0,
'arrow-parens': 0,
'import/first': 1,
'no-return-await': 0,
'flowtype/define-flow-type': 1,
'flowtype/use-flow-type': 1,
'import/namespace': [2, { allowComputed: true }],
'import/no-duplicates': 1,
'import/order': [2, { 'newlines-between': 'always-and-inside-groups' }],
'no-unused-vars': [
2,
{
ignoreRestSiblings: true,
},
],
'no-await-in-loop': 0,
'no-plusplus': 0,
'import/prefer-default-export': 0,
'no-confusing-arrow': 0,
'no-restricted-syntax': 0,
'no-bitwise': 0,
'function-paren-newline': 0,
'object-curly-newline': 0,
'import/no-cycle': 1,
'import/no-unresolved': [2, { ignore: ['@entria/graphql-mongoose-loader'] }],
'import/no-self-import': 1,
'import/extensions': [0, 'never', { ts: 'never' }],
indent: 0,
'@typescript-eslint/indent': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'interface-over-type-literal': 0,
'@typescript-eslint/consistent-type-definitions': 0,
'lines-between-class-members': 0,
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/prefer-interface': 0,
'@typescript-eslint/interface-name-prefix': 0,
'@typescript-eslint/no-non-null-assertion': 1,
'@typescript-eslint/no-var-requires': 1,
'@typescript-eslint/no-object-literal-type-assertion': 1,
'import/no-extraneous-dependencies': 1,
'prefer-const': [
2,
{
destructuring: 'all',
},
],
'no-multi-assign': 1,
},
plugins: ['flowtype', 'react', 'import', '@typescript-eslint'],
globals: {
require: true,
},
env: {
jest: true,
node: true,
es6: true,
browser: true,
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
'eslint-import-resolver-typescript': true,
'eslint-import-resolver-lerna': {
packages: path.resolve(__dirname, 'packages'),
},
},
},
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
const id = correlations?.id;
What did you expect to happen? it should keep like this:
const id = correlations?.id;
What actually happened? Please include the actual, raw output from ESLint. it changed to
const { id } = correlations;
causing a bug
Are you willing to submit a pull request to fix this bug?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
prefer-destructuring - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Refactoring optional chaining into a large codebase - Lea Verou
Now that optional chaining is supported across the board, I decided to finally refactor Mavo to use it (yes, yes, we do provide...
Read more >Overzealous Destructuring | Aleksandr Hovhannisyan
So destructuring the data is more dangerous than defensive coding (like using the optional chaining operator or good-old if statements).
Read more >Should I just be using optional chaining expression ... - Reddit
Teach me how to destructure a 4 level nested object that is retrieved from an API request for rendering without using optional chaining...
Read more >Optional Chaining - Function.prototype.apply was called on ...
This is definitely a bug - their experimental implementation of the optional chaining does not work with how they transpile calls with spread ......
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
updated
@typescript-eslint/parser
tks
@sibelius which version of
@typescript-eslint/parser
are you using? It looks like this shouldn’t happen with2.4.0
and above.