add js and ts lints
This commit is contained in:
13
.eslintrc
Normal file
13
.eslintrc
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": ["vtex"],
|
||||||
|
"ignorePatterns": [
|
||||||
|
"__mocks__/",
|
||||||
|
"__generated__/"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["**/*.tsx"],
|
||||||
|
"extends": ["vtex-react"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Action Cable provides the framework to deal with WebSockets in Rails.
|
// Action Cable provides the framework to deal with WebSockets in Rails.
|
||||||
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.
|
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.
|
||||||
|
|
||||||
import { createConsumer } from "@rails/actioncable"
|
import { createConsumer } from "@rails/actioncable";
|
||||||
|
|
||||||
export default createConsumer()
|
export default createConsumer();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Load all the channels within this directory and all subdirectories.
|
// Load all the channels within this directory and all subdirectories.
|
||||||
// Channel files must be named *_channel.js.
|
// Channel files must be named *_channel.js.
|
||||||
|
|
||||||
const channels = require.context('.', true, /_channel\.js$/)
|
const channels = require.context(".", true, /_channel\.js$/);
|
||||||
channels.keys().forEach(channels)
|
|
||||||
|
channels.keys().forEach(channels);
|
||||||
|
|||||||
12
app/javascript/modules.d.ts
vendored
12
app/javascript/modules.d.ts
vendored
@@ -1,8 +1,8 @@
|
|||||||
declare module "@rails/ujs"
|
declare module "@rails/ujs";
|
||||||
declare module "turbolinks"
|
declare module "turbolinks";
|
||||||
declare module "@rails/activestorage"
|
declare module "@rails/activestorage";
|
||||||
|
|
||||||
declare module '*.png' {
|
declare module "*.png" {
|
||||||
const png: string
|
const png: string;
|
||||||
export default png
|
export default png;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,4 @@
|
|||||||
// Turbolinks.start()
|
// Turbolinks.start()
|
||||||
// ActiveStorage.start()
|
// ActiveStorage.start()
|
||||||
|
|
||||||
import "stylesheets/application"
|
import "stylesheets/application";
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
import '../src/index'
|
import "../src/index";
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import React from "react"
|
import React from "react";
|
||||||
import {
|
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
|
||||||
BrowserRouter as Router,
|
|
||||||
Switch,
|
|
||||||
Route,
|
|
||||||
} from "react-router-dom";
|
|
||||||
import { AppContext } from "./contexts/AppContext";
|
import { AppContext } from "./contexts/AppContext";
|
||||||
import { AuthProvider } from "./contexts/AuthProvider";
|
import { AuthProvider } from "./contexts/AuthProvider";
|
||||||
import { Home } from "./pages";
|
import { Home } from "./pages";
|
||||||
@@ -26,5 +23,5 @@ export const App = () => {
|
|||||||
</main>
|
</main>
|
||||||
</AppContext>
|
</AppContext>
|
||||||
</AuthProvider>
|
</AuthProvider>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import * as React from "react";
|
import type { FC } from "react";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
export type HeaderProps = {};
|
export const Header: FC = ({ children }) => {
|
||||||
|
|
||||||
export const Header = ({ children }: React.PropsWithChildren<HeaderProps>) => {
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-64 bg-gradient-to-br from-green-300 to-green-400 grid place-items-center">
|
<div className="w-full h-64 bg-gradient-to-br from-green-300 to-green-400 grid place-items-center">
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { useAuth0 } from "@auth0/auth0-react";
|
import { useAuth0 } from "@auth0/auth0-react";
|
||||||
import XStakeLogo from '../images/logo.png'
|
|
||||||
|
import XStakeLogo from "../images/logo.png";
|
||||||
import { useAppContext } from "../contexts/AppContext";
|
import { useAppContext } from "../contexts/AppContext";
|
||||||
|
|
||||||
export const Navbar = () => {
|
export const Navbar = () => {
|
||||||
const { setSideNavExpanded } = useAppContext()
|
const { setSideNavExpanded } = useAppContext();
|
||||||
|
|
||||||
const handleExpandSideNav = () => {
|
const handleExpandSideNav = () => {
|
||||||
setSideNavExpanded((prevState) => !prevState);
|
setSideNavExpanded((prevState) => !prevState);
|
||||||
@@ -35,9 +36,9 @@ export const Navbar = () => {
|
|||||||
</button>
|
</button>
|
||||||
<img
|
<img
|
||||||
src={XStakeLogo}
|
src={XStakeLogo}
|
||||||
alt={"XStake Logo"}
|
alt="XStake Logo"
|
||||||
width={64}
|
width={64}
|
||||||
placeholder={"blurred"}
|
placeholder="blurred"
|
||||||
/>
|
/>
|
||||||
<h1 className="text-2xl font-bold">XStake</h1>
|
<h1 className="text-2xl font-bold">XStake</h1>
|
||||||
<div className="w-full h-full flex items-center justify-end">
|
<div className="w-full h-full flex items-center justify-end">
|
||||||
|
|||||||
@@ -1,35 +1,50 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import cx from "classnames";
|
import cx from "classnames";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
import { useAppContext } from "../contexts/AppContext";
|
import { useAppContext } from "../contexts/AppContext";
|
||||||
|
|
||||||
type MenuItem = {
|
type MenuItem = {
|
||||||
label: string;
|
label: string;
|
||||||
|
path: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MenuItems: MenuItem[] = [
|
const MenuItems: MenuItem[] = [
|
||||||
{
|
{
|
||||||
label: "Início",
|
label: "Início",
|
||||||
|
path: "/",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Stake",
|
label: "Stake",
|
||||||
|
path: "/stake",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Carteira",
|
label: "Carteira",
|
||||||
|
path: "/wallet",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
export const SideNav = () => {
|
export const SideNav = () => {
|
||||||
const { sideNavExpanded, setSideNavExpanded } = useAppContext()
|
const { sideNavExpanded, setSideNavExpanded } = useAppContext();
|
||||||
|
|
||||||
const handleCloseSideNav = () => {
|
const handleCloseSideNav = () => {
|
||||||
setSideNavExpanded(false);
|
setSideNavExpanded(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleKeyPress = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
handleCloseSideNav();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed left-0 right-0 bottom-0 mt-16 top-0 z-40 xl:static xl:w-72">
|
<div
|
||||||
|
className="fixed left-0 right-0 bottom-0 mt-16 top-0 z-40 xl:static xl:w-72"
|
||||||
|
role="menu"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
role="row"
|
role="none"
|
||||||
|
onKeyPress={handleKeyPress}
|
||||||
onClick={() => handleCloseSideNav()}
|
onClick={() => handleCloseSideNav()}
|
||||||
className={cx(
|
className={cx(
|
||||||
"xl:hidden absolute w-full h-full bg-black bg-opacity-60 backdrop-filter backdrop-blur-sm z-30 transition-all duration-500",
|
"xl:hidden absolute w-full h-full bg-black bg-opacity-60 backdrop-filter backdrop-blur-sm z-30 transition-all duration-500",
|
||||||
@@ -43,12 +58,11 @@ export const SideNav = () => {
|
|||||||
>
|
>
|
||||||
<ul>
|
<ul>
|
||||||
{MenuItems.map((item) => (
|
{MenuItems.map((item) => (
|
||||||
<li
|
<Link to={item.path} key={item.label} role="menuitem">
|
||||||
key={item.label}
|
<li className="text-xl p-4 px-8 hover:bg-gray-100 cursor-pointer">
|
||||||
className="text-xl p-4 px-8 hover:bg-gray-100 cursor-pointer"
|
{item.label}
|
||||||
>
|
</li>
|
||||||
<a href="#">{item.label}</a>
|
</Link>
|
||||||
</li>
|
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import React, { createContext, Dispatch, FC, SetStateAction, useContext, useState } from 'react'
|
import type { Dispatch, FC, SetStateAction } from "react";
|
||||||
|
import React, { createContext, useContext, useState } from "react";
|
||||||
|
|
||||||
export type AppContext = {
|
export type AppContext = {
|
||||||
setSideNavExpanded: Dispatch<SetStateAction<boolean>>
|
setSideNavExpanded: Dispatch<SetStateAction<boolean>>;
|
||||||
sideNavExpanded: boolean
|
sideNavExpanded: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
const Context = createContext<AppContext | null>(null)
|
const Context = createContext<AppContext | null>(null);
|
||||||
|
|
||||||
export const useAppContext = (): AppContext => {
|
export const useAppContext = (): AppContext => {
|
||||||
const context = useContext(Context);
|
const context = useContext(Context);
|
||||||
@@ -18,11 +19,11 @@ export const useAppContext = (): AppContext => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const AppContext: FC = ({ children }) => {
|
export const AppContext: FC = ({ children }) => {
|
||||||
const [sideNavExpanded, setSideNavExpanded] = useState(false)
|
const [sideNavExpanded, setSideNavExpanded] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Context.Provider value={{ sideNavExpanded, setSideNavExpanded }}>
|
<Context.Provider value={{ sideNavExpanded, setSideNavExpanded }}>
|
||||||
{children}
|
{children}
|
||||||
</Context.Provider>
|
</Context.Provider>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import { Auth0Provider } from '@auth0/auth0-react'
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||||
import React, { FC } from 'react'
|
import { Auth0Provider } from "@auth0/auth0-react";
|
||||||
|
import type { FC } from "react";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
export const AuthProvider: FC = ({children}) => {
|
export const AuthProvider: FC = ({ children }) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const domain = window.AUTH_DOMAIN
|
const domain = window.AUTH_DOMAIN;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const clientId = window.AUTH_CLIENT_ID
|
const clientId = window.AUTH_CLIENT_ID;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const audience = window.AUTH_AUDIENCE
|
const audience = window.AUTH_AUDIENCE;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Auth0Provider
|
<Auth0Provider
|
||||||
@@ -18,5 +20,5 @@ export const AuthProvider: FC = ({children}) => {
|
|||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Auth0Provider>
|
</Auth0Provider>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import React from 'react'
|
import React from "react";
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from "react-dom";
|
||||||
import { App } from './App'
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
import { App } from "./App";
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
document.getElementById('root'),
|
document.getElementById("root")
|
||||||
)
|
);
|
||||||
})
|
});
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import React, { FC } from 'react'
|
import type { FC } from "react";
|
||||||
import { Container } from '../../components/Container'
|
import React from "react";
|
||||||
import { Header } from '../../components/Header'
|
|
||||||
import { Navbar } from '../../components/Navbar'
|
import { Container } from "../../components/Container";
|
||||||
import { PoolListing } from '../../components/PoolListing'
|
import { Header } from "../../components/Header";
|
||||||
import { SideNav } from '../../components/SideNav'
|
import { Navbar } from "../../components/Navbar";
|
||||||
|
import { PoolListing } from "../../components/PoolListing";
|
||||||
|
import { SideNav } from "../../components/SideNav";
|
||||||
|
|
||||||
export const Home: FC = () => {
|
export const Home: FC = () => {
|
||||||
return (
|
return (
|
||||||
@@ -26,5 +28,5 @@ export const Home: FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export * from './Home'
|
export * from "./Home";
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export * from './Home'
|
export * from "./Home";
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export * from './Home'
|
export * from "./Home";
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ module.exports = {
|
|||||||
extend: {
|
extend: {
|
||||||
spacing: {
|
spacing: {
|
||||||
...defaultTheme.spacing,
|
...defaultTheme.spacing,
|
||||||
'full': '100%',
|
full: "100%",
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
variants: {
|
variants: {
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
"name": "x-stake",
|
"name": "x-stake",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "./bin/webpack-dev-server"
|
"dev": "./bin/webpack-dev-server",
|
||||||
|
"lint": "eslint --ext .jsx,.js,.tsx,.ts app/javascript/",
|
||||||
|
"lint:fix": "eslint --fix --ext .jsx,.js,.tsx,.ts app/javascript/",
|
||||||
|
"tsc": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@auth0/auth0-react": "^1.6.0",
|
"@auth0/auth0-react": "^1.6.0",
|
||||||
@@ -32,6 +35,10 @@
|
|||||||
"@types/ramda": "^0.27.44",
|
"@types/ramda": "^0.27.44",
|
||||||
"@types/react-router-dom": "^5.1.8",
|
"@types/react-router-dom": "^5.1.8",
|
||||||
"dotenv-webpack": "^7.0.3",
|
"dotenv-webpack": "^7.0.3",
|
||||||
|
"eslint": "^7.32.0",
|
||||||
|
"eslint-config-vtex": "^14.1.0",
|
||||||
|
"eslint-config-vtex-react": "^8.1.0",
|
||||||
|
"prettier": "^2.3.2",
|
||||||
"webpack-dev-server": "^3.11.2"
|
"webpack-dev-server": "^3.11.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user