Skip to content

Instantly share code, notes, and snippets.

@LevPewPew
Last active February 16, 2022 07:37
Show Gist options
  • Save LevPewPew/5791c7f1b4ccd688d5a8f1a8c6d95c0f to your computer and use it in GitHub Desktop.
Save LevPewPew/5791c7f1b4ccd688d5a8f1a8c6d95c0f to your computer and use it in GitHub Desktop.
starter config for TS CRA on Github
# Ignore everything:
/*
# Except src:
!/src
{
"extends": ["react-app", "eslint:recommended"],
"rules": {
"default-case": "error",
"default-case-last": "error",
"default-param-last": "error",
"eqeqeq": "error",
"no-alert": "warn",
"no-console": "warn",
"no-magic-numbers": "warn",
"no-redeclare": "off", // original no-redeclare rule must be turned off as it can return in correct errors, see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-redeclare.md
"@typescript-eslint/no-redeclare": "error",
"no-self-compare": "error",
"no-shadow": "warn",
"no-unreachable-loop": "warn",
"no-unsafe-optional-chaining": "error",
"no-unused-expressions": "warn",
"no-unused-vars": "warn",
"no-useless-return": "error",
"require-await": "error",
"yoda": "error"
}
}
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Run jest tests
run: npm run test
- name: Check for build errors
run: npm run build
# Ignore everything:
/*
# Except src:
!/src
{
"printWidth": 100,
"trailingComma": "all",
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
}
# need a specific version of husky to avoid an issue with prettier (i've forgotted what the error was)
yarn add --dev [email protected] prettier pretty-quick
// add this pre-commit hook to the rest of the file
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}
{
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
// this might need to be "jsx": "react" if it isn't the latest CRA where you don't need to import React
"jsx": "react-jsx",
"noImplicitAny": true
},
"include": ["src/**/*.ts"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment