Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

chore(workspace): Merge eslint presets into a single preset (#2841)

Changed files
+143 -197
packages
core
src
preact-urql
react-urql
site
plugins
monorepo-fix
src
scripts
+1 -16
package.json
···
"./scripts/eslint/preset.js"
]
},
-
"overrides": [
-
{
-
"files": [
-
"examples/**/*"
-
],
-
"extends": [
-
"./scripts/eslint/js-preset.js"
-
]
-
}
-
],
-
"eslintIgnore": [
-
"packages/site/dist-prod",
-
"docs"
-
],
"prettier": {
"singleQuote": true,
"arrowParens": "avoid",
"trailingComma": "es5"
},
"lint-staged": {
-
"*.{ts,tsx}": "eslint -c scripts/eslint/preset.js --fix",
-
"*.{js,jsx}": "eslint -c scripts/eslint/js-preset.js --fix",
+
"*.{js,jsx,ts,tsx}": "eslint -c scripts/eslint/preset.js --fix",
"*.json": "prettier --write",
"*.md": "prettier --write"
},
+2 -3
packages/core/src/utils/error.test.ts
···
networkError: new Error('test'),
});
-
expect(err instanceof CombinedError).toBe(true);
-
expect(err instanceof Error).toBe(true);
-
expect(Error.prototype.isPrototypeOf(err)).toBe(true);
+
expect(err).toBeInstanceOf(CombinedError);
+
expect(err).toBeInstanceOf(Error);
expect('' + err).toMatchSnapshot();
});
+1 -1
packages/preact-urql/src/hooks/useQuery.test.tsx
···
};
let state: UseQueryState<any> | undefined;
-
let execute: ((opts?: Partial<OperationContext>) => void) | undefined;
+
let execute: ((_opts?: Partial<OperationContext>) => void) | undefined;
const QueryUser: FC<UseQueryArgs<{ myVar: number }>> = ({
query,
+2 -2
packages/preact-urql/src/hooks/useSubscription.test.tsx
···
const query = 'subscription Example { example }';
let state: UseSubscriptionState<any> | undefined;
-
let execute: ((opts?: Partial<OperationContext>) => void) | undefined;
+
let execute: ((_opts?: Partial<OperationContext>) => void) | undefined;
const SubscriptionUser: FC<{
q: string;
-
handler?: (prev: any, data: any) => any;
+
handler?: (_prev: any, _data: any) => any;
context?: Partial<OperationContext>;
pause?: boolean;
}> = ({ q, handler, context, pause = false }) => {
+1 -1
packages/react-urql/src/hooks/useQuery.test.tsx
···
};
let state: UseQueryState<any> | undefined;
-
let execute: ((opts?: Partial<OperationContext>) => void) | undefined;
+
let execute: ((_opts?: Partial<OperationContext>) => void) | undefined;
const QueryUser = ({
query,
+2 -2
packages/react-urql/src/hooks/useSubscription.test.tsx
···
const query = 'subscription Example { example }';
let state: UseSubscriptionState<any> | undefined;
-
let execute: ((opts?: Partial<OperationContext>) => void) | undefined;
+
let execute: ((_opts?: Partial<OperationContext>) => void) | undefined;
const SubscriptionUser = ({
q,
···
pause = false,
}: {
q: string;
-
handler?: (prev: any, data: any) => any;
+
handler?: (_prev: any, _data: any) => any;
context?: Partial<OperationContext>;
pause?: boolean;
}) => {
-9
packages/site/package.json
···
"babel-plugin-styled-components"
]
},
-
"eslintConfig": {
-
"root": true,
-
"extends": [
-
"../../scripts/eslint/js-preset.js"
-
]
-
},
-
"eslintIgnore": [
-
"dist-prod"
-
],
"dependencies": {
"@babel/runtime": "^7.20.1",
"@mdx-js/react": "^1.6.22",
+1 -1
packages/site/plugins/monorepo-fix/node.api.js
···
config.externals = [
...config.externals,
(context, request, callback) => {
-
if (/^[.\/]/.test(request)) {
+
if (/^[./]/.test(request)) {
return callback();
}
-1
packages/site/src/components/mdx.js
···
import styled, { css } from 'styled-components';
import { MDXProvider } from '@mdx-js/react';
import { Link } from 'react-router-dom';
-
import { useMarkdownPage } from 'react-static-plugin-md-pages';
import Highlight, { Prism } from 'prism-react-renderer';
import nightOwlLight from 'prism-react-renderer/themes/nightOwlLight';
+1 -1
packages/site/src/components/panel.js
···
color: #e3eef8;
display: flex;
justify-content: center;
-
${p => (!!p.isLight ? light : dark)};
+
${p => (p.isLight ? light : dark)};
${p => p.background && `background: ${p.background}`}
`;
+1 -2
packages/site/src/components/sidebar.js
···
import Fuse from 'fuse.js';
import { Link, useLocation } from 'react-router-dom';
-
import { useMarkdownPage, useMarkdownTree } from 'react-static-plugin-md-pages';
+
import { useMarkdownTree } from 'react-static-plugin-md-pages';
import {
SidebarNavItem,
···
const [filterTerm, setFilterTerm] = useState('');
const location = useLocation();
const tree = useMarkdownTree();
-
const page = useMarkdownPage();
const sidebarItems = useMemo(() => {
let pathname = location.pathname.match(/docs\/?(.+)?/);
+1 -1
packages/site/src/screens/404/404.js
···
import React from 'react';
-
const NotFound = props => {
+
const NotFound = () => {
return <h1>404! That page does not exist :(</h1>;
};
-37
packages/site/src/screens/home/get-started.js
···
}
`;
-
const GithubButton = styled.a`
-
background-color: white;
-
display: flex;
-
flex-direction: row;
-
height: 4rem;
-
padding: 0.5rem 1rem;
-
width: 18rem;
-
align-items: center;
-
justify-content: center;
-
-
img {
-
width: 1.6rem;
-
}
-
p {
-
margin: 0;
-
font-size: 14px;
-
margin-left: 2rem;
-
text-decoration: none;
-
color: black;
-
letter-spacing: 1px;
-
color: #383838;
-
}
-
&:active {
-
p {
-
color: black;
-
}
-
}
-
&:visited {
-
p {
-
color: black;
-
}
-
}
-
&:hover {
-
background-color: #f6f6f6;
-
}
-
`;
-
const GetStartedTitle = styled(SectionTitle)`
margin: 2rem 0 4rem;
`;
+1 -4
packages/site/src/screens/home/hero.js
···
-
import React, { useState, useCallback } from 'react';
+
import React, { useCallback } from 'react';
import { Link as ReactRouterLink } from 'react-router-dom';
import { Wrapper } from '../../components/wrapper';
···
};
const Hero = props => {
-
const [animating, setAnimating] = useState(false);
-
const [copied, setCopied] = useState(false);
-
const handleCopy = useCallback(
e => {
if (!navigator.clipboard) {
-1
packages/site/src/screens/home/more-oss.js
···
import { PanelSectionWrapper } from '../../components/panel';
import { SectionTitle } from '../../components/section-title';
import { SecondaryTitle } from '../../components/secondary-title';
-
import { Wrapper } from '../../components/wrapper';
const OSSCardContainer = styled.div`
display: grid;
-15
packages/site/src/styles/global.js
···
import { createGlobalStyle } from 'styled-components';
-
const systemFonts = [
-
'-apple-system',
-
'BlinkMacSystemFont',
-
'Segoe UI',
-
'Roboto',
-
'Helvetica Neue',
-
'Arial',
-
'Noto Sans',
-
'sans-serif',
-
'Apple Color Emoji',
-
'Segoe UI Emoji',
-
'Segoe UI Symbol',
-
'Noto Color Emoji',
-
];
-
export const GlobalStyle = createGlobalStyle`
* {
box-sizing: inherit;
-71
scripts/eslint/common.js
···
-
module.exports = {
-
parserOptions: {
-
ecmaVersion: 9,
-
sourceType: 'module',
-
ecmaFeatures: {
-
modules: true,
-
jsx: true,
-
},
-
},
-
extends: [
-
'plugin:react/recommended',
-
'prettier',
-
],
-
ignorePatterns: [
-
'node_modules/',
-
'dist/',
-
'build/',
-
'coverage/',
-
'benchmark/',
-
'scripts/'
-
],
-
plugins: [
-
'react-hooks',
-
'prettier',
-
'es5',
-
],
-
rules: {
-
'react-hooks/rules-of-hooks': 'error',
-
'react-hooks/exhaustive-deps': 'warn',
-
'react/react-in-jsx-scope': 'off',
-
'react/prop-types': 'off',
-
'react/no-children-prop': 'off',
-
'sort-keys': 'off',
-
'no-console': ['error', { allow: ['warn', 'error'] }],
-
'prefer-arrow/prefer-arrow-functions': 'off',
-
-
'es5/no-for-of': 'off',
-
'es5/no-generators': 'off',
-
'es5/no-typeof-symbol': 'warn',
-
-
'prettier/prettier': ['error', {
-
singleQuote: true,
-
arrowParens: 'avoid',
-
trailingComma: 'es5',
-
}],
-
},
-
globals: {
-
"vi": true
-
},
-
overrides: [
-
{
-
files: [
-
'*.test.ts',
-
'*.test.tsx',
-
'*.spec.ts',
-
'*.spec.tsx',
-
],
-
rules: {
-
'es5/no-for-of': 'off',
-
'es5/no-generators': 'off',
-
'es5/no-typeof-symbol': 'off',
-
}
-
}
-
],
-
-
settings: {
-
react: {
-
version: 'detect',
-
},
-
},
-
};
-12
scripts/eslint/js-preset.js
···
-
module.exports = {
-
extends: [
-
'./common.js',
-
],
-
rules: {
-
'consistent-return': 'warn',
-
'no-magic-numbers': 'off', // TODO
-
'react/jsx-key': 'off',
-
'react/jsx-handler-names': 'off',
-
'es5/no-es6-methods': 'off',
-
},
-
};
+129 -17
scripts/eslint/preset.js
···
module.exports = {
parser: '@typescript-eslint/parser',
-
extends: [
-
'./common.js',
-
'plugin:@typescript-eslint/recommended',
+
parserOptions: {
+
ecmaVersion: 9,
+
sourceType: 'module',
+
ecmaFeatures: {
+
modules: true,
+
jsx: true,
+
},
+
},
+
+
ignorePatterns: [
+
'node_modules/',
+
'dist/',
+
'dist-prod/',
+
'build/',
+
'coverage/',
+
'benchmark/',
+
'scripts/',
+
'docs/',
+
],
+
+
settings: {
+
react: {
+
version: 'detect',
+
},
+
},
+
+
extends: ['eslint:recommended', 'prettier'],
+
+
plugins: [
+
'@typescript-eslint',
'prettier',
+
'es5',
],
+
rules: {
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
-
'@typescript-eslint/no-use-before-define': 'off',
-
'@typescript-eslint/ban-types': 'off',
-
'@typescript-eslint/ban-ts-comment': 'off',
-
'@typescript-eslint/member-ordering': 'off',
-
'@typescript-eslint/explicit-member-accessibility': 'off',
-
'@typescript-eslint/no-object-literal-type-assertion': 'off',
-
'@typescript-eslint/explicit-function-return-type': 'off',
-
'@typescript-eslint/interface-name-prefix': 'off',
-
'@typescript-eslint/no-non-null-assertion': 'off',
-
'@typescript-eslint/no-misused-new': 'off',
-
'@typescript-eslint/no-explicit-any': 'off',
-
'@typescript-eslint/array-type': 'off',
+
'no-undef': 'off',
+
'no-empty': 'off',
+
'sort-keys': 'off',
+
'no-console': ['error', { allow: ['warn', 'error'] }],
+
'prefer-arrow/prefer-arrow-functions': 'off',
-
'@typescript-eslint/no-unused-vars': ['error', {
+
'es5/no-for-of': 'off',
+
'es5/no-generators': 'off',
+
'es5/no-typeof-symbol': 'warn',
+
+
'no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
}],
+
+
'prettier/prettier': ['error', {
+
singleQuote: true,
+
arrowParens: 'avoid',
+
trailingComma: 'es5',
+
}],
},
+
+
overrides: [
+
{
+
extends: ['plugin:@typescript-eslint/recommended'],
+
files: ['*.ts'],
+
rules: {
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
+
'@typescript-eslint/no-use-before-define': 'off',
+
'@typescript-eslint/ban-types': 'off',
+
'@typescript-eslint/ban-ts-comment': 'off',
+
'@typescript-eslint/member-ordering': 'off',
+
'@typescript-eslint/explicit-member-accessibility': 'off',
+
'@typescript-eslint/no-object-literal-type-assertion': 'off',
+
'@typescript-eslint/explicit-function-return-type': 'off',
+
'@typescript-eslint/interface-name-prefix': 'off',
+
'@typescript-eslint/no-non-null-assertion': 'off',
+
'@typescript-eslint/no-misused-new': 'off',
+
'@typescript-eslint/no-explicit-any': 'off',
+
'@typescript-eslint/array-type': 'off',
+
'import/no-internal-modules': 'off',
+
+
'@typescript-eslint/no-unused-vars': ['error', {
+
argsIgnorePattern: '^_',
+
}],
+
},
+
},
+
+
{
+
extends: ['plugin:@typescript-eslint/recommended'],
+
files: ['*.tsx'],
+
extends: ['plugin:react/recommended'],
+
plugins: ['react-hooks'],
+
rules: {
+
'react-hooks/rules-of-hooks': 'error',
+
'react-hooks/exhaustive-deps': 'warn',
+
'react/react-in-jsx-scope': 'off',
+
'react/prop-types': 'off',
+
'react/no-children-prop': 'off',
+
},
+
},
+
+
{
+
files: ['*.test.ts', '*.test.tsx', '*.spec.ts', '*.spec.tsx'],
+
globals: { vi: true },
+
rules: {
+
'@typescript-eslint/ban-ts-comment': 'off',
+
'es5/no-for-of': 'off',
+
'es5/no-generators': 'off',
+
'es5/no-typeof-symbol': 'off',
+
}
+
},
+
+
{
+
files: ['*.js'],
+
rules: {
+
'@typescript-eslint/no-var-requires': 'off',
+
'consistent-return': 'warn',
+
'no-magic-numbers': 'off',
+
'es5/no-es6-methods': 'off',
+
},
+
},
+
+
{
+
files: ['*.jsx'],
+
extends: ['plugin:react/recommended'],
+
rules: {
+
'consistent-return': 'warn',
+
'no-magic-numbers': 'off',
+
'react/jsx-key': 'off',
+
'react/jsx-handler-names': 'off',
+
'es5/no-es6-methods': 'off',
+
},
+
},
+
+
{
+
files: ['examples/**/*.jsx'],
+
rules: {
+
'react/prop-types': 'off',
+
},
+
},
+
],
};