Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ESlint config; update dependencies #7

Merged
merged 10 commits into from
Feb 20, 2022
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Enable custom ESLint config
# https://create-react-app.dev/docs/setting-up-your-editor/#experimental-extending-the-eslint-config
EXTEND_ESLINT=true

# Convert ESLint errors to warnings in development
# https://github.com/facebook/create-react-app/issues/9887#issuecomment-772741743
ESLINT_NO_DEV_ERRORS = true
31 changes: 22 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ module.exports = {
extends: [
"react-app",
"airbnb-base",
"plugin:prettier/recommended",
"airbnb-typescript",
"plugin:react/recommended",
"plugin:prettier/recommended",
"prettier",
],
parserOptions: {
project: ["./tsconfig.json", "./cypress/tsconfig.json"],
},
overrides: [
{
files: [
Expand Down Expand Up @@ -60,20 +65,27 @@ module.exports = {
},
],
"import/no-anonymous-default-export": "error", // https://github.com/c-hive/guides/blob/a82e1b37ef662c8f8d7485793f99970080f40dca/js/best-practices.md#name-functions-when-exporting
"import/no-extraneous-dependencies": [ // https://stackoverflow.com/q/44939304/2771889
"import/no-extraneous-dependencies": [
// https://stackoverflow.com/q/44939304/2771889
"error",
{
devDependencies: ["**/*.test.ts", "**/*.test.tsx", "src/setupTests.ts", "src/test-utils.tsx"],
devDependencies: [
"**/*.test.ts",
"**/*.test.tsx",
"src/setupTests.ts",
"src/test-utils.tsx",
],
},
],
"import/extensions": [ // https://stackoverflow.com/a/59268871/2771889
"import/extensions": [
// https://stackoverflow.com/a/59268871/2771889
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
js: "never",
jsx: "never",
ts: "never",
tsx: "never",
},
],
"react/prop-types": "off", // https://github.com/c-hive/cra-typescript-starter/issues/1
Expand All @@ -89,7 +101,8 @@ module.exports = {
react: {
version: "detect",
},
"import/resolver": { // https://stackoverflow.com/a/55280867/2771889
"import/resolver": {
// https://stackoverflow.com/a/55280867/2771889
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
paths: ["src"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on: [push]

env:
node_version: "12.x"
node_version: "16.10.x"

jobs:
lint:
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
}
7 changes: 6 additions & 1 deletion cypress/plugins/index.js → cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
/**
* @type {Cypress.PluginConfig}
*/
module.exports = () => {
const config = (
_on: Cypress.PluginEvents,
_config: Cypress.PluginConfigOptions
) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};

export default config;
40 changes: 15 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,17 @@
"alphach": "^0.0.1",
"hex-rgb": "^4.1.0",
"raw.macro": "^0.4.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-ga": "^3.1.2",
"react-helmet": "^6.1.0",
"react-markdown": "^4.3.1",
"react-markdown": "^8.0.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.0",
"react-scripts": "5.0.0",
"serve": "^11.3.2",
"styled-components": "^5.1.1",
"typescript": "~3.7.2"
},
"//resolutions": {
"@typescript-eslint": "https://github.com/typescript-eslint/typescript-eslint/issues/1746"
},
"resolutions": {
"@typescript-eslint/eslint-plugin": "2.23.0",
"@typescript-eslint/parser": "2.23.0",
"@typescript-eslint/typescript-estree": "2.23.0"
},
"browserslist": {
"production": [
">0.2%",
Expand All @@ -63,23 +55,21 @@
"last 1 safari version"
]
},
"engines": {
"npm": ">=6.6"
},
"//devDependencies": {
"eslint*": "Code style. Packages part of `react-scripts` should not be added here, otherwise there might be verion mismatches: https://github.com/typescript-eslint/typescript-eslint/issues/2193",
"prettier": "code formatting"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.2",
"@testing-library/react": "^10.4.8",
"cypress": "^4.12.1",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-cypress": "^2.11.1",
"eslint-plugin-jest": "^23.17.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-testing-library": "^3.4.1",
"prettier": "^2.0.5"
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"cypress": "^9.5.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^16.1.0",
"eslint-config-prettier": "^8.4.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-jest": "^26.1.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-testing-library": "^5.0.5",
"prettier": "^2.5.1"
}
}
2 changes: 1 addition & 1 deletion src/components/App/Legal/Legal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Legal: FunctionComponent = () => {
</Helmet>
<Box p={1} pt={[2, 4]} pb={[4, 8]}>
<Container>
<ReactMarkdown source={raw("../../../resources/legal.md")} />
<ReactMarkdown>{raw("../../../resources/legal.md")}</ReactMarkdown>
</Container>
</Box>
</>
Expand Down
3 changes: 2 additions & 1 deletion src/typings/material-ui.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ThemeOptions } from "@material-ui/core/styles/createMuiTheme";
// ESLint weirdness here but `ThemeOptions` must be imported
import { ThemeOptions as _ThemeOptions } from "@material-ui/core/styles/createMuiTheme";

declare module "@material-ui/core/styles/createMuiTheme" {
export interface ThemeOptions {
Expand Down
13 changes: 7 additions & 6 deletions src/utils/tracking/tracking.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { fireEvent, render } from "test-utils";
import ReactGA from "react-ga";
import { screen } from "@testing-library/react";

import Example from "./tracking.example";
import { trackEvent } from "./tracking";
Expand All @@ -17,7 +18,7 @@ const ciUrl = "https://www.vanity.services?env=CI";
describe("usePageTracking", () => {
describe(`when URL is ${url}`, () => {
let location: Location;
const mockLocation = (new URL(url) as unknown) as Location;
const mockLocation = new URL(url) as unknown as Location;

beforeEach(() => {
location = window.location;
Expand All @@ -41,8 +42,8 @@ describe("usePageTracking", () => {
});

it("tracks page change", () => {
const { getByText } = render(<Example />);
fireEvent.click(getByText("Page"));
render(<Example />);
fireEvent.click(screen.getByText("Page"));
expect(ReactGA.pageview).toHaveBeenCalledWith("/page");
});
});
Expand All @@ -61,7 +62,7 @@ describe("usePageTracking", () => {

describe("when URL has CI env params", () => {
let location: Location;
const mockLocation = (new URL(ciUrl) as unknown) as Location;
const mockLocation = new URL(ciUrl) as unknown as Location;

beforeEach(() => {
location = window.location;
Expand Down Expand Up @@ -95,7 +96,7 @@ describe("trackEvent", () => {

describe(`when URL is ${url}`, () => {
let location: Location;
const mockLocation = (new URL(url) as unknown) as Location;
const mockLocation = new URL(url) as unknown as Location;

beforeEach(() => {
location = window.location;
Expand Down Expand Up @@ -125,7 +126,7 @@ describe("trackEvent", () => {

describe("when URL has CI env params", () => {
let location: Location;
const mockLocation = (new URL(ciUrl) as unknown) as Location;
const mockLocation = new URL(ciUrl) as unknown as Location;

beforeEach(() => {
location = window.location;
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"baseUrl": "src"
"baseUrl": "src",
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
"src",
".eslintrc.js"
],
"typeRoots": [
"src/typings",
Expand Down
Loading