vite please play nice with eslint

This commit is contained in:
Dane Johnson 2023-02-14 22:26:04 -06:00
parent 87e85ed52f
commit ffaef7419c
4 changed files with 68 additions and 22 deletions

View File

@ -1,31 +1,49 @@
// -*- mode: web; -*-
module.exports = {
"env": {
"browser": true,
"es2021": true
env: {
browser: true,
es2021: true,
},
"extends": [
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json",
"tsconfigRootDir": __dirname,
overrides: [],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {},
"settings": {
"react": {
"version": "detect",
plugins: ["react", "@typescript-eslint"],
// typescript-eslint disables a bunch of rules that tsc would catch, but vite refuses to
// add compiler errors to output, so here we are
rules: {
"constructor-super": "error",
"getter-return": "error",
"no-const-assign": "error",
"no-dupe-args": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-func-assign": "error",
"no-import-assign": "error",
"no-new-symbol": "error",
"no-obj-calls": "error",
"no-redeclare": "error",
"no-setter-return": "error",
"no-this-before-super": "error",
"no-undef": "error",
"no-unreachable": "error",
"no-unsafe-negation": "error",
"valid-typeof": "error",
},
settings: {
react: {
version: "detect",
},
},
}
};

View File

@ -1,15 +1,19 @@
import { useEffect } from "react";
import { Stack, Container } from "react-bootstrap";
import { isEmpty } from "lodash";
import { socket } from "./socket";
import { useAppSelector } from "./hooks";
import { selectRoomCode } from "./store/socketSlice";
import { selectContestants } from "./store/displaySlice";
import { selectCategories } from "./store/cluesSlice";
import ContestantWidget from "./ContestantWidget";
import Gameboard from "./display/Gameboard";
const Display = () => {
const roomCode = useAppSelector(selectRoomCode);
const contestants = useAppSelector(selectContestants);
const categories = useAppSelector(selectCategories);
useEffect(() => {
socket.emit("new-game");
@ -20,6 +24,9 @@ const Display = () => {
<Container>
<h1 className="text-center">Room code is: {roomCode}</h1>
</Container>
{!isEmpty(categories) && <Gameboard categories={categories} />}
<Stack
direction="horizontal"
gap={10}

21
src/display/Gameboard.tsx Normal file
View File

@ -0,0 +1,21 @@
import { Container, Row, Col } from "react-bootstrap";
import type { Category } from "../store/cluesSlice";
interface Props {
categories: Category[];
}
const Gameboard = ({ categories }: Props) => {
return (
<Container fluid>
<Row>
{categories.map(({ name }) => (
<Col key={name}>{name}</Col>
))}
</Row>
</Container>
);
};
export default Gameboard;

View File

@ -6,7 +6,7 @@ interface CluesState {
categories: Category[];
}
interface Category {
export interface Category {
name: string;
clues: Clue[];
}