Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
node: true,
es6: true,
},
plugins: ["@typescript-eslint", "react", "react-hooks", "unused-imports"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier",
],
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["warn"],
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/no-floating-promises": "warn",
"no-extra-boolean-cast": "warn",
"react/prop-types": "off",

// Currently this repo uses "any" and is generally loose
// on typing, so turning off some rules that might be
// best practice in the long run.
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",

// Added css module declartion if we want to move away
// from using require when importing css class names
// but turning this off for now
"@typescript-eslint/no-require-imports": "off",
},
settings: {
react: {
version: "detect",
},
},
ignorePatterns: ["node_modules/", "public/", ".cache/"],
// TODO: opted to override linting for the preview templates
// as its too much to handle during the initial migration
// They are typed very generally and loosely
overrides: [
{
files: ["src/cms/preview-templates/**/*.tsx"],
rules: {
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
],
};
28 changes: 28 additions & 0 deletions .github/workflows/lint-and-typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint and Typecheck

on:
push:
branches: [main, production]
pull_request:
branches: [main, production]

jobs:
lint-and-typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint

- name: Run TypeScript typecheck
run: npm run typecheck
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint && npm run typecheck || exit 1
2 changes: 1 addition & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
// DEV_SSR: true,
// },
plugins: [
"gatsby-plugin-react-helmet",
"gatsby-plugin-react-helmet-async",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like for SSR the async version of react-helmet is preferred, and is also more maintained. I have yet to confirm what it does, and what this has changed. I just made the linter happy.

The Helmet is an example of something where I am unclear if we are intentionally implementing it or it is a legacy from the template used to start the repo.

"gatsby-plugin-fix-fouc",
"gatsby-remark-line-breaks",
{
Expand Down
Loading
Loading