Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-array-index-key rule not working with Optional chaining (?.) #2896

Closed
refaelok opened this issue Jan 3, 2021 · 0 comments · Fixed by #2897
Closed

no-array-index-key rule not working with Optional chaining (?.) #2896

refaelok opened this issue Jan 3, 2021 · 0 comments · Fixed by #2897

Comments

@refaelok
Copy link

refaelok commented Jan 3, 2021

While using chinning condition, no-array-index-key are not recognize using index as key.
The following code example are not display any lint issue:

const someArray = [1, 2, 3, 4, 5];

someArray?.map((code, index) => (
	<option key={index} value={code}>
		{code}
	</option>
))
Configuration

.eslintrc


{
  "root": true,
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint"
  ],
  "settings": {
    "react": {
      "version": "detect" // Tells eslint-plugin-react to automatically detect the version of React to use
    }
  },
  "extends": [
    "airbnb-typescript",
    "plugin:react/recommended",
    "plugin:harmony-boilerplate/recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "parserOptions": {
    "project": "./tsconfig.json",
    "ecmaVersion": 2020, // Allows for the parsing of modern ECMAScript features
    "sourceType": "module", // Allows for the use of imports
    "ecmaFeatures": {
      "jsx": true // Allows for the parsing of JSX
    }
  },
  "rules": {
    "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
    "react/sort-comp": ["off"],
    "react/prefer-stateless-function": ["off"],
    "import/no-named-as-default": ["off"],
    "arrow-body-style": ["off"],
    "import/order": ["off"],
    "func-names": ["off"],
    "guard-for-in": ["off"],
    "lines-between-class-members": ["off"],
    "jsx-a11y/label-has-associated-control": ["off"],
    "import/prefer-default-export": "off",
    "import/no-default-export": "off",
    "react/jsx-one-expression-per-line": ["off"],
    "class-methods-use-this": ["off"],
    "max-len": ["error", { "code": 180 }],
    "@typescript-eslint/explicit-function-return-type": ["off"],
    "@typescript-eslint/no-use-before-define": ["off"],
    "@typescript-eslint/no-explicit-any": ["off"],
    "no-trailing-spaces": ["error", { "skipBlankLines": true, "ignoreComments": true }],
    "react/jsx-props-no-spreadings": ["off"],
    "linebreak-style": 0,
    "global-require": 0,
    "eslint-linebreak-style": [0, "error", "windows"],
    "indent": ["error", "tab", { "SwitchCase": 1 }],
    "no-tabs": ["error", { "allowIndentationTabs": true }],
    "react/jsx-indent-props": ["error", "tab"],
    "react/jsx-indent": ["error", "tab"],
    "@typescript-eslint/indent": ["error", "tab"],
    "comma-dangle": ["error", "only-multiline"],
    "no-console": 1
  }
}

package.json


{
  "name": "harmony-boilerplate-client",
  "version": "2.0.0",
  "description": "Harmony Boilerplate gives you the best developer experience with all the features you need for production based react redux: react routers & mobile rendering, TypeScript support, smart bundling, sagas, and more. No config needed.",
  "main": "index.js",
  "repository": "",
  "scripts": {
    "clean:dist": "rimraf dist",
    "lint": "esw ./src --ext .ts,.tsx",
    "lint:watch": "esw ./src --ext .ts,.tsx -w --color",
    "lint:test": "esw ./test --ext .ts,.tsx",
    "lint-and-fix": "eslint ./src --ext .ts,.tsx --fix",
    "lite": "npm run clean:dist && poi --prod && lite-server",
    "build": "npm run lint && poi --prod",
    "serve": "poi --serve",
    "dev": "npm run serve",
    "start": "npm-run-all --parallel lint:watch dev",
    "test": "npm run lint:test && tsc --noEmit && jest"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/cli": "7.8.4",
    "@babel/core": "7.9.6",
    "@babel/node": "7.8.7",
    "@babel/plugin-proposal-class-properties": "7.8.3",
    "@babel/plugin-proposal-decorators": "7.8.3",
    "@babel/preset-env": "7.1.6",
    "@babel/preset-react": "7.0.0",
    "@babel/register": "7.0.0",
    "@poi/plugin-typescript": "12.3.1",
    "@types/expect-puppeteer": "2.2.1",
    "@types/jest": "22.2.3",
    "@types/jest-environment-puppeteer": "2.2.0",
    "@types/node": "13.13.5",
    "@types/puppeteer": "1.2.3",
    "@typescript-eslint/eslint-plugin": "2.33.0",
    "@typescript-eslint/parser": "2.33.0",
    "babel-loader": "8.0.4",
    "chai": "4.2.0",
    "chai-jquery": "2.1.0",
    "copy-webpack-plugin": "6.2.0",
    "cross-env": "5.2.0",
    "enzyme": "3.10.0",
    "enzyme-adapter-react-16": "1.14.0",
    "eslint": "7.13.0",
    "eslint-config-airbnb-typescript": "7.2.1",
    "eslint-plugin-harmony-boilerplate": "^1.0.3",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsx-a11y": "6.2.3",
    "eslint-plugin-react": "7.20.0",
    "eslint-plugin-react-hooks": "4.0.2",
    "eslint-watch": "6.0.1",
    "eslint-webpack-plugin": "2.4.1",
    "gulp": "4.0.2",
    "gulp-footer": "1.1.2",
    "gulp-header": "1.8.12",
    "gulp-inject": "4.3.2",
    "gulp-inject-string": "1.1.1",
    "gulp-rename": "1.4.0",
    "gulp-replace": "0.5.4",
    "gulp-sass": "3.2.1",
    "gulp-template": "4.0.0",
    "jest": "26.0.1",
    "jest-puppeteer": "2.4.0",
    "jquery": "3.5.1",
    "jsdom": "8.5.0",
    "lite-server": "^2.5.4",
    "mocha": "7.1.2",
    "npm-run-all": "latest",
    "poi": "12.10.3",
    "react-hot-loader": "4.12.21",
    "rimraf": "2.6.2",
    "sass-loader": "8.0.2",
    "sinon": "6.2.0",
    "ts-jest": "26.0.0",
    "ts-loader": "7.0.3",
    "tsconfig-paths-webpack-plugin": "3.2.0",
    "typescript": "3.8.3"
  },
  "dependencies": {
    "@types/history": "4.7.6",
    "@types/lodash": "^4.14.161",
    "@types/moment": "2.13.0",
    "@types/react": "16.9.34",
    "@types/react-dom": "16.9.7",
    "@types/react-redux": "7.1.8",
    "@types/react-router": "5.1.8",
    "@types/react-router-dom": "5.1.5",
    "@types/redux-form": "8.2.5",
    "@types/seamless-immutable": "7.1.12",
    "@types/react-toast-notifications": "2.4.0",
    "axios": "0.18.1",
    "bcryptjs": "2.4.3",
    "bootstrap": "4.4.1",
    "guid": "0.0.12",
    "history": "4.10.1",
    "lodash": "^4.17.20",
    "moment": "2.27.0",
    "react": "16.13.1",
    "react-bootstrap": "1.0.1",
    "react-device-detect": "1.12.1",
    "react-dom": "16.13.1",
    "react-localize-redux": "3.5.3",
    "react-redux": "7.2.0",
    "react-redux-spinner": "2.0.0",
    "react-router": "5.2.0",
    "react-router-dom": "5.2.0",
    "react-toast-notifications": "2.4.0",
    "reduce-reducers": "1.0.4",
    "redux": "4.0.5",
    "redux-devtools-extension": "2.13.5",
    "redux-flow-manager": "~1.0.40",
    "redux-form": "8.3.5",
    "redux-persist": "6.0.0",
    "redux-saga": "1.1.3",
    "redux-simple-cart": "0.2.1",
    "reduxsauce": "1.1.2",
    "seamless-immutable": "7.1.4",
    "uuid": "~8.3.0",
    "ws": "3.3.1",
    "ws-reconnect-js": "1.0.4"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants