🚨 Add eslint and stylelint and format
This commit is contained in:
1 parent
f0656b34e9
commit
2ed0c57b97
13 files changed
+5999
-48
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
src/types.ts
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
module.exports = {
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
},
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2020,
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
"plugin:prettier/recommended",
|
||||||
|
"plugin:react/recommended",
|
||||||
|
"plugin:import/errors",
|
||||||
|
"plugin:import/warnings",
|
||||||
|
"plugin:import/typescript",
|
||||||
|
"plugin:react/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
],
|
||||||
|
rules: {
|
||||||
|
"no-console": "off",
|
||||||
|
"prefer-destructuring": "off",
|
||||||
|
"import/no-extraneous-dependencies": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
devDependencies: ["**/*.test.js", "**/*.spec.js", "**/__tests__/**"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"import/prefer-default-export": "off",
|
||||||
|
"import/order": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
groups: ["builtin", "external", "internal", ["parent", "sibling", "index"]],
|
||||||
|
"newlines-between": "always",
|
||||||
|
alphabetize: { order: "asc" },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"react-hooks/exhaustive-deps": "error",
|
||||||
|
"react-hooks/rules-of-hooks": "error",
|
||||||
|
"react/button-has-type": "error",
|
||||||
|
"react/jsx-filename-extension": ["warn", { extensions: [".js", ".jsx", ".ts", ".tsx"] }],
|
||||||
|
"react/jsx-uses-react": "off",
|
||||||
|
"react/prefer-stateless-function": "warn",
|
||||||
|
"react/prop-types": "off",
|
||||||
|
"react/react-in-jsx-scope": "off",
|
||||||
|
"react/sort-comp": "off",
|
||||||
|
},
|
||||||
|
plugins: ["prettier", "react", "react-hooks"],
|
||||||
|
settings: {
|
||||||
|
react: {
|
||||||
|
version: "detect",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 120
|
||||||
|
}
|
||||||
Generated
+5863
File diff suppressed because it is too large.
Load diff
+23
-3
@@ -3,18 +3,22 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
|
"dev": "vite",
|
||||||
|
"format:js": "eslint --fix src",
|
||||||
|
"format:styles": "stylelint --fix src",
|
||||||
"generate": "graphql-codegen",
|
"generate": "graphql-codegen",
|
||||||
|
"lint:js": "eslint src",
|
||||||
|
"lint:styles": "stylelint src",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/client": "^3.4.16",
|
"@apollo/client": "^3.4.16",
|
||||||
|
"graphql": "^15.7.2",
|
||||||
"react": "^17.0.0",
|
"react": "^17.0.0",
|
||||||
"react-dom": "^17.0.0",
|
"react-dom": "^17.0.0"
|
||||||
"graphql": "^15.7.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@graphql-codegen/cli": "^2.2.2",
|
"@graphql-codegen/cli": "^2.2.2",
|
||||||
@@ -22,8 +26,24 @@
|
|||||||
"@graphql-codegen/typescript-react-apollo": "^3.2.0",
|
"@graphql-codegen/typescript-react-apollo": "^3.2.0",
|
||||||
"@types/react": "^17.0.0",
|
"@types/react": "^17.0.0",
|
||||||
"@types/react-dom": "^17.0.0",
|
"@types/react-dom": "^17.0.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
||||||
|
"@typescript-eslint/parser": "^4.31.2",
|
||||||
"@vitejs/plugin-react": "^1.0.0",
|
"@vitejs/plugin-react": "^1.0.0",
|
||||||
|
"@vitejs/plugin-react-refresh": "^1.3.6",
|
||||||
|
"eslint": "^7.32.0",
|
||||||
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
"eslint-plugin-import": "^2.24.2",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"eslint-plugin-react": "^7.26.0",
|
||||||
|
"eslint-plugin-react-hooks": "^4.2.0",
|
||||||
"jest": "^27.3.1",
|
"jest": "^27.3.1",
|
||||||
|
"prettier": "^2.4.1",
|
||||||
|
"stylelint": "^13.13.1",
|
||||||
|
"stylelint-config-idiomatic-order": "^8.1.0",
|
||||||
|
"stylelint-config-prettier": "^8.0.2",
|
||||||
|
"stylelint-config-recommended": "^5.0.0",
|
||||||
|
"stylelint-order": "^4.1.0",
|
||||||
|
"stylelint-prettier": "^1.2.0",
|
||||||
"typescript": "^4.3.2",
|
"typescript": "^4.3.2",
|
||||||
"vite": "^2.6.4"
|
"vite": "^2.6.4"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
.App {
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
import { ApolloProvider } from "@apollo/client";
|
import { ApolloProvider } from "@apollo/client";
|
||||||
import React from 'react'
|
import React from "react";
|
||||||
|
|
||||||
import logo from './assets/brick.svg';
|
import styles from "./App.module.css";
|
||||||
import styles from './App.module.css'
|
import logo from "./assets/brick.svg";
|
||||||
import {Register} from "./features/Register";
|
|
||||||
import client from "./client";
|
import client from "./client";
|
||||||
|
import { Register } from "./features/Register";
|
||||||
|
|
||||||
function App() {
|
const App: React.FC = () => (
|
||||||
return (
|
|
||||||
<ApolloProvider client={client}>
|
<ApolloProvider client={client}>
|
||||||
<div className={styles.app}>
|
<div className={styles.app}>
|
||||||
<img src={logo} className={styles.logo} alt="logo" />
|
<img src={logo} className={styles.logo} alt="logo" />
|
||||||
<Register />
|
<Register />
|
||||||
</div>
|
</div>
|
||||||
</ApolloProvider>
|
</ApolloProvider>
|
||||||
)
|
);
|
||||||
}
|
|
||||||
|
|
||||||
export default App
|
export default App;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ApolloClient, InMemoryCache } from "@apollo/client";
|
import { ApolloClient, InMemoryCache } from "@apollo/client";
|
||||||
|
|
||||||
const client = new ApolloClient({
|
const client = new ApolloClient({
|
||||||
uri: 'http://localhost:8000/graphql/', // FIXME: env
|
uri: "http://localhost:8000/graphql/", // FIXME: env
|
||||||
cache: new InMemoryCache()
|
cache: new InMemoryCache(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default client;
|
export default client;
|
||||||
@@ -1,17 +1,21 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import {Product, useAllProductsQuery} from '../types';
|
import { Product, useAllProductsQuery } from "../types";
|
||||||
|
|
||||||
export const Register: React.FC = () => {
|
export const Register: React.FC = () => {
|
||||||
const { data, error, loading } = useAllProductsQuery({ variables: { active: true } });
|
const { data, error, loading } = useAllProductsQuery({ variables: { active: true } });
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log('🔥', error)
|
console.log("🔥", error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <div>...</div>
|
return <div>...</div>;
|
||||||
}
|
}
|
||||||
return (<div>{data?.allProducts.map((product: Product) => {
|
return (
|
||||||
return <div key={product.id}>{product.name}</div>
|
<div>
|
||||||
})} </div>)
|
{data?.allProducts.map((product: Product) => {
|
||||||
|
return <div key={product.id}>{product.name}</div>;
|
||||||
|
})}{" "}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import React from 'react'
|
import React from "react";
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from "react-dom";
|
||||||
import App from './App'
|
|
||||||
|
import App from "./App";
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
document.getElementById('root')
|
document.getElementById("root")
|
||||||
)
|
);
|
||||||
+21
-19
@@ -1,10 +1,10 @@
|
|||||||
import { gql } from '@apollo/client';
|
import { gql } from "@apollo/client";
|
||||||
import * as Apollo from '@apollo/client';
|
import * as Apollo from "@apollo/client";
|
||||||
export type Maybe<T> = T | null;
|
export type Maybe<T> = T | null;
|
||||||
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
||||||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
||||||
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
||||||
const defaultOptions = {}
|
const defaultOptions = {};
|
||||||
/** All built-in and custom scalars, mapped to their actual values */
|
/** All built-in and custom scalars, mapped to their actual values */
|
||||||
export type Scalars = {
|
export type Scalars = {
|
||||||
ID: string;
|
ID: string;
|
||||||
@@ -15,35 +15,35 @@ export type Scalars = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type Product = {
|
export type Product = {
|
||||||
__typename?: 'Product';
|
__typename?: "Product";
|
||||||
id: Scalars['ID'];
|
id: Scalars["ID"];
|
||||||
name: Scalars['String'];
|
name: Scalars["String"];
|
||||||
salePriceExt: Scalars['Float'];
|
salePriceExt: Scalars["Float"];
|
||||||
salePriceInt: Scalars['Float'];
|
salePriceInt: Scalars["Float"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ProductFilter = {
|
export type ProductFilter = {
|
||||||
active?: Maybe<Scalars['Boolean']>;
|
active?: Maybe<Scalars["Boolean"]>;
|
||||||
id?: Maybe<Scalars['ID']>;
|
id?: Maybe<Scalars["ID"]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Query = {
|
export type Query = {
|
||||||
__typename?: 'Query';
|
__typename?: "Query";
|
||||||
allProducts: Array<Product>;
|
allProducts: Array<Product>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export type QueryAllProductsArgs = {
|
export type QueryAllProductsArgs = {
|
||||||
filters?: Maybe<ProductFilter>;
|
filters?: Maybe<ProductFilter>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AllProductsQueryVariables = Exact<{
|
export type AllProductsQueryVariables = Exact<{
|
||||||
active: Scalars['Boolean'];
|
active: Scalars["Boolean"];
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
export type AllProductsQuery = {
|
||||||
export type AllProductsQuery = { __typename?: 'Query', allProducts: Array<{ __typename?: 'Product', id: string, name: string, salePriceExt: number, salePriceInt: number }> };
|
__typename?: "Query";
|
||||||
|
allProducts: Array<{ __typename?: "Product"; id: string; name: string; salePriceExt: number; salePriceInt: number }>;
|
||||||
|
};
|
||||||
|
|
||||||
export const AllProductsDocument = gql`
|
export const AllProductsDocument = gql`
|
||||||
query allProducts($active: Boolean!) {
|
query allProducts($active: Boolean!) {
|
||||||
@@ -73,11 +73,13 @@ export const AllProductsDocument = gql`
|
|||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
export function useAllProductsQuery(baseOptions: Apollo.QueryHookOptions<AllProductsQuery, AllProductsQueryVariables>) {
|
export function useAllProductsQuery(baseOptions: Apollo.QueryHookOptions<AllProductsQuery, AllProductsQueryVariables>) {
|
||||||
const options = {...defaultOptions, ...baseOptions}
|
const options = { ...defaultOptions, ...baseOptions };
|
||||||
return Apollo.useQuery<AllProductsQuery, AllProductsQueryVariables>(AllProductsDocument, options);
|
return Apollo.useQuery<AllProductsQuery, AllProductsQueryVariables>(AllProductsDocument, options);
|
||||||
}
|
}
|
||||||
export function useAllProductsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AllProductsQuery, AllProductsQueryVariables>) {
|
export function useAllProductsLazyQuery(
|
||||||
const options = {...defaultOptions, ...baseOptions}
|
baseOptions?: Apollo.LazyQueryHookOptions<AllProductsQuery, AllProductsQueryVariables>
|
||||||
|
) {
|
||||||
|
const options = { ...defaultOptions, ...baseOptions };
|
||||||
return Apollo.useLazyQuery<AllProductsQuery, AllProductsQueryVariables>(AllProductsDocument, options);
|
return Apollo.useLazyQuery<AllProductsQuery, AllProductsQueryVariables>(AllProductsDocument, options);
|
||||||
}
|
}
|
||||||
export type AllProductsQueryHookResult = ReturnType<typeof useAllProductsQuery>;
|
export type AllProductsQueryHookResult = ReturnType<typeof useAllProductsQuery>;
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
declare module "*.svg" {
|
declare module "*.svg" {
|
||||||
const content: any;
|
const content: unknown;
|
||||||
export default content;
|
export default content;
|
||||||
}
|
}
|
||||||
declare module "*.module.css";
|
declare module "*.module.css";
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: ["stylelint-config-recommended", "stylelint-prettier/recommended", "stylelint-config-idiomatic-order"],
|
||||||
|
plugins: ["stylelint-order"],
|
||||||
|
rules: {
|
||||||
|
// Useful?
|
||||||
|
"no-descending-specificity": null,
|
||||||
|
},
|
||||||
|
ignoreFiles: ["**/*.md", "**/*.svg", "**/*.jpg", "**/*.graphql"],
|
||||||
|
};
|
||||||
Reference in new issue
Block a user