From 6c29558df08e3f248bbad82e88935113a2ee9a08 Mon Sep 17 00:00:00 2001 From: HIMANSHU Date: Fri, 12 Apr 2024 03:35:26 +0530 Subject: [PATCH] Added Stricter linters --- .eslintrc.js | 125 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 94 insertions(+), 31 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 04e262f..d73f980 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,30 +1,46 @@ - const fs = require('fs'); const path = require('path'); + const prettierOptions = JSON.parse( fs.readFileSync(path.resolve(__dirname, '.prettierrc'), 'utf8'), ); - -// const app = JSON.parse(path.resolve(__dirname, 'app')); - module.exports = { root: true, parser: 'babel-eslint', - extends: ['airbnb', 'prettier', 'prettier/react'], - plugins: ['prettier', 'redux-saga', 'react-native', 'react', 'react-hooks', 'jsx-a11y'], + extends: [ + 'airbnb', + 'prettier', + 'prettier/react', + 'plugin:prettier/recommended', + 'plugin:sonarjs/recommended', + 'plugin:security/recommended-legacy', + 'plugin:fp/recommended' + ], + plugins: [ + 'github', + 'immutable', + 'sonarjs', + 'prettier', + 'redux-saga', + 'react-native', + 'react', + 'react-hooks', + 'jsx-a11y', + 'fp' + ], env: { jest: true, browser: true, node: true, - es6: true, + es6: true }, parserOptions: { ecmaVersion: 6, sourceType: 'module', ecmaFeatures: { - jsx: true, - }, + jsx: true + } }, rules: { 'prettier/prettier': ['error', prettierOptions], @@ -53,8 +69,8 @@ module.exports = { // NOTE: If this error triggers, either disable it or add // your custom components, labels and attributes via these options // See https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-associated-control.md - controlComponents: ['Input'], - }, + controlComponents: ['Input'] + } ], 'jsx-a11y/label-has-for': 0, 'jsx-a11y/mouse-events-have-key-events': 2, @@ -82,29 +98,76 @@ module.exports = { 'redux-saga/no-yield-in-race': 2, 'redux-saga/yield-effects': 2, 'require-yield': 0, - 'react/no-array-index-key': 0 + 'react/no-array-index-key': 0, + 'react/jsx-curly-newline': 0, + 'react/jsx-one-expression-per-line': 0, + 'react/jsx-wrap-multilines': 0, + 'react/no-unused-prop-types': 0, + 'max-lines-per-function': ['error', 250], + 'no-else-return': 'error', + 'max-params': ['error', 3], + 'require-jsdoc': [ + 'error', + { + require: { + FunctionDeclaration: true, + MethodDefinition: false, + ClassDeclaration: false, + ArrowFunctionExpression: false, + FunctionExpression: false + } + } + ], + 'no-shadow': 'error', + complexity: ['error', 10], + 'no-empty': 'error', + 'import/order': [ + 'error', + { + groups: [ + ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'] + ] + } + ], + 'immutable/no-let': 2, + 'immutable/no-this': 2, + 'max-lines': ['error', 350], + 'react-native/no-unused-styles': 2, + 'react-native/split-platform-components': 2, + 'react-native/no-inline-styles': 2, + 'react-native/no-color-literals': 2, + 'react-native/no-raw-text': 2, + 'react-native/no-single-element-style-arrays': 2, + 'fp/no-mutation': [ + 'error', + { + exceptions: [{ property: 'propTypes' }, { property: 'defaultProps' }] + } + ], + 'fp/no-nil': 0, + 'fp/no-unused-expression': 0 }, - "settings": { - "import/resolver": { - "node": { - "app": "./app", - "context": "app", - "resolve": { - "alias": { - "@assets": "./app/assets", - "@components": "./app/components", - "@containers": "./app/containers", - "@config": "./app/config", - "@navigators": "./app/navigators", - "@services": "./app/services", - "@themes": "./app/themes", - "@utils": "./app/utils" + settings: { + 'import/resolver': { + node: { + app: './app', + context: 'app', + resolve: { + alias: { + '@assets': './app/assets', + '@components': './app/components', + '@containers': './app/containers', + '@config': './app/config', + '@navigators': './app/navigators', + '@services': './app/services', + '@themes': './app/themes', + '@utils': './app/utils' }, - "paths": ["app"], - "modules": ["app", 'node_modules'], - "extensions": ['.js', '.jsx', '.json', '.coffee', '.cjsx'], + paths: ['app'], + modules: ['app', 'node_modules'], + extensions: ['.js', '.jsx', '.json', '.coffee', '.cjsx'] } } } } -} +}; \ No newline at end of file