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

Feature/linters v2 #90

Merged
merged 4 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 95 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 All @@ -38,6 +54,7 @@ module.exports = {
'import/no-unresolved': 0,
'import/prefer-default-export': 0,
'react/jsx-props-no-spreading': 0,
'camelcase': ['error', { 'properties': 'always', ignoreImports: false}],
indent: [
2,
2,
Expand All @@ -53,8 +70,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 +99,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']
}
}
}
}
}
};
himanshu-wedensday marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 3 additions & 2 deletions app/components/atoms/If/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
*
*/
// 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 = {
// eslint-disable-next-line fp/no-mutation
If.propTypes = {
condition: Proptypes.bool,
otherwise: Proptypes.oneOfType([
Proptypes.arrayOf(Proptypes.node),
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.
*/
himanshu-wedensday marked this conversation as resolved.
Show resolved Hide resolved
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 babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @param {Function} api.cache - Function used for caching Babel configuration.
* @returns {object} Babel configuration object with presets and plugins.
*/
// eslint-disable-next-line fp/no-mutation
module.exports = function(api = { cache: () => {} }) {
api.cache(true);
return {
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