chore: use common eslint config for most packages (#4705)
Split from https://github.com/twentyhq/twenty/pull/4518 Related to #4766 Mutualizes eslint config between projects. I didn't include `twenty-server` in this PR as this was causing too many lint errors.
This commit is contained in:
@ -1,60 +1,14 @@
|
||||
// eslint-disable-next-line
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
extends: [
|
||||
'plugin:@nx/react',
|
||||
'plugin:react/recommended',
|
||||
'plugin:react-hooks/recommended',
|
||||
'plugin:storybook/recommended',
|
||||
'../../.eslintrc.js',
|
||||
],
|
||||
plugins: ['react-hooks', 'react-refresh'],
|
||||
extends: ['../../.eslintrc.cjs', '../../.eslintrc.react.cjs'],
|
||||
ignorePatterns: ['!**/*', 'node_modules', 'dist', 'src/generated/*.tsx'],
|
||||
rules: {
|
||||
'@nx/workspace-effect-components': 'error',
|
||||
'@nx/workspace-no-hardcoded-colors': 'error',
|
||||
'@nx/workspace-matching-state-variable': 'error',
|
||||
'@nx/workspace-sort-css-properties-alphabetically': 'error',
|
||||
'@nx/workspace-styled-components-prefixed-with-styled': 'error',
|
||||
'@nx/workspace-no-state-useref': 'error',
|
||||
'@nx/workspace-component-props-naming': 'error',
|
||||
|
||||
'react/no-unescaped-entities': 'off',
|
||||
'react/prop-types': 'off',
|
||||
'react/jsx-key': 'off',
|
||||
'react/display-name': 'off',
|
||||
'react/jsx-uses-react': 'off',
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/jsx-no-useless-fragment': 'off',
|
||||
'react/jsx-props-no-spreading': [
|
||||
'error',
|
||||
{
|
||||
explicitSpread: 'ignore',
|
||||
},
|
||||
],
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
||||
files: ['*.ts', '*.tsx'],
|
||||
parserOptions: {
|
||||
project: ['packages/twenty-chrome-extension/tsconfig.*?.json'],
|
||||
project: ['packages/twenty-chrome-extension/tsconfig.{json,*.json}'],
|
||||
},
|
||||
rules: {},
|
||||
},
|
||||
{
|
||||
files: ['.storybook/main.@(js|cjs|mjs|ts)'],
|
||||
rules: {
|
||||
'storybook/no-uninstalled-addons': [
|
||||
'error',
|
||||
{ packageJsonLocation: path.resolve('../../package.json') },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['.storybook/**/*', '**/*.stories.tsx', '**/*.test.@(ts|tsx)'],
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
'@nx/workspace-explicit-boolean-predicates-in-if': 'warn',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { OperationVariables } from '@apollo/client';
|
||||
import { isUndefined } from '@sniptt/guards';
|
||||
import { DocumentNode } from 'graphql';
|
||||
|
||||
import getApolloClient from '~/utils/apolloClient';
|
||||
@ -11,11 +12,9 @@ export const callQuery = async <T>(
|
||||
|
||||
const { data, error } = await client.query<T>({ query, variables });
|
||||
|
||||
if (error) throw new Error(error.message);
|
||||
if (!isUndefined(error)) throw new Error(error.message);
|
||||
|
||||
if (data) return data;
|
||||
|
||||
return null;
|
||||
return data ?? null;
|
||||
};
|
||||
|
||||
export const callMutation = async <T>(
|
||||
@ -26,9 +25,7 @@ export const callMutation = async <T>(
|
||||
|
||||
const { data, errors } = await client.mutate<T>({ mutation, variables });
|
||||
|
||||
if (errors) throw new Error(errors[0].message);
|
||||
if (!isUndefined(errors)) throw new Error(errors[0].message);
|
||||
|
||||
if (data) return data;
|
||||
|
||||
return null;
|
||||
return data ?? null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user