Skip to content

Commit

Permalink
feat: Stricter Linters
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-wedensday committed Apr 16, 2024
1 parent ed12ebb commit 2774b94
Show file tree
Hide file tree
Showing 12 changed files with 1,286 additions and 52 deletions.
125 changes: 94 additions & 31 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -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],
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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']
}
}
}
}
}
};
27 changes: 15 additions & 12 deletions app/components/atoms/If/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
*
*/
// eslint-disable-next-line
import React from 'react'
import React from 'react';
import Proptypes from 'prop-types';
const If = props => (props.condition ? props.children : props.otherwise);
If.propsTypes = {
condition: Proptypes.bool,
otherwise: Proptypes.oneOfType([
Proptypes.arrayOf(Proptypes.node),
Proptypes.node
]),
children: Proptypes.oneOfType([
Proptypes.arrayOf(Proptypes.node),
Proptypes.node
])
};
// eslint-disable-next-line fp/no-mutating-assign
Object.assign(If, {
propsTypes: {
condition: Proptypes.bool,
otherwise: Proptypes.oneOfType([
Proptypes.arrayOf(Proptypes.node),
Proptypes.node
]),
children: Proptypes.oneOfType([
Proptypes.arrayOf(Proptypes.node),
Proptypes.node
])
}
});
If.defaultProps = {
otherwise: null
};
Expand Down
1 change: 1 addition & 0 deletions app/components/atoms/LanguageProvider/reducer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-small-switch */
/*
*
* LanguageProvider reducer
Expand Down
11 changes: 11 additions & 0 deletions app/components/molecules/CharacterWithQuote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ const CharacterImage = styled.Image`
margin: 0 auto;
`;

/**
* Renders a component displaying a character with associated quote and image.
*
* @component
* @param {Object} props - The props object.
* @param {Object} props.user - The user object containing character and quote information.
* @param {string} props.user.character - The character name to display.
* @param {string} props.user.image - The URL of the image associated with the character.
* @param {string} props.user.quote - The quote associated with the character.
* @returns {JSX.Element} A React element representing the character display with quote.
*/
function CharacterWithQuote({ user }) {
return (
<>
Expand Down
1 change: 1 addition & 0 deletions app/i18n.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable fp/no-mutating-assign */
/**
* i18n.js
*
Expand Down
1 change: 1 addition & 0 deletions app/scenes/RootScreen/reducer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-small-switch */
import { createActions } from 'reduxsauce';
import { fromJS } from 'immutable';
import produce from 'immer';
Expand Down
9 changes: 8 additions & 1 deletion app/scenes/RootScreen/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import { rootScreenTypes } from './reducer';
export function* startup() {
setTimeout(() => navigateAndReset('MainScreen'), 1000);
}

/**
* Generator function for the startup saga.
* Watches for the latest occurrence of the specified action type and triggers the startup process.
*
* @generator
* @function startUpSaga
* @yields {Effect} Effect object representing the takeLatest behavior
*/
export default function* startUpSaga() {
yield takeLatest(rootScreenTypes.STARTUP, startup);
}
1 change: 1 addition & 0 deletions app/services/navigationService.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable fp/no-mutating-assign */
import { NavigationActions, StackActions } from '@react-navigation/compat';
/**
* The navigation is implemented as a service so that it can be used outside of components, for example in sagas.
Expand Down
2 changes: 2 additions & 0 deletions app/utils/apiUtils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable sonarjs/no-small-switch */
/* eslint-disable fp/no-mutating-assign */
import { create } from 'apisauce';
import mapKeysDeep from 'map-keys-deep';
import camelCase from 'lodash/camelCase';
Expand Down
1 change: 1 addition & 0 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

// eslint-disable-next-line fp/no-mutation
module.exports = getDefaultConfig(__dirname);
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
"axios-mock-adapter": "^1.17.0",
"babel-plugin-react-intl": "3.0.1",
"babel-preset-react-native": "^4.0.1",
"eslint-plugin-fp": "^2.3.0",
"eslint-plugin-github": "^4.10.2",
"eslint-plugin-immutable": "^1.0.0",
"eslint-plugin-security": "^3.0.0",
"eslint-plugin-sonarjs": "^0.25.1",
"expo": "~47.0.14",
"expo-image-picker": "~14.0.1",
"expo-splash-screen": "~0.17.5",
Expand Down
Loading

0 comments on commit 2774b94

Please sign in to comment.