Created
April 6, 2020 12:58
-
-
Save RyanHirsch/1ac4b6bee54f6a724b67c314da056f91 to your computer and use it in GitHub Desktop.
Typescript + Jest + ESLint + Tailwind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.next | |
__generated__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"parser": "@typescript-eslint/parser", | |
"parserOptions": { | |
"project": "./tsconfig.eslint.json" | |
}, | |
"plugins": ["@typescript-eslint"], | |
"extends": [ | |
"eslint:recommended", | |
"plugin:react/recommended", | |
"plugin:@typescript-eslint/eslint-recommended", | |
"plugin:@typescript-eslint/recommended", | |
"plugin:@typescript-eslint/recommended-requiring-type-checking", | |
"prettier", | |
"prettier/@typescript-eslint", | |
"plugin:prettier/recommended" | |
], | |
"rules": { | |
"@typescript-eslint/no-empty-interface": "off", | |
"@typescript-eslint/no-unused-vars": [ | |
"error", | |
{ "argsIgnorePattern": "^_" } | |
], | |
"@typescript-eslint/no-use-before-define": "off", | |
"react/react-in-jsx-scope": "off" | |
}, | |
"settings": { | |
"react": { | |
"version": "detect" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.next | |
__generated__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "tailwindcss/base"; | |
@import "tailwindcss/components"; | |
@import "tailwindcss/utilities"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn add tailwindcss postcss-import autoprefixer @fullhuman/postcss-purgecss | |
yarn add -D \ | |
eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react \ | |
prettier eslint-config-prettier eslint-plugin-prettier \ | |
jest @testing-library/jest-dom @testing-library/react ts-jest \ | |
lint-staged husky npm-run-all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-env node */ | |
module.exports = { | |
preset: "ts-jest/presets/js-with-ts", | |
moduleFileExtensions: ["ts", "tsx", "js"], | |
moduleNameMapper: {}, | |
transform: { | |
"^.+\\.(ts|tsx)$": "ts-jest", | |
}, | |
testMatch: ["**/__tests__/*.(ts|tsx)"], | |
setupFilesAfterEnv: ["./jest.setup.ts"], | |
testPathIgnorePatterns: ["./.next/", "./node_modules/"], | |
globals: { | |
"ts-jest": { | |
tsConfig: "tsconfig.jest.json", | |
}, | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "@testing-library/jest-dom"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"lint": "yarn codegen && npm-run-all -p lint:*", | |
"lint:tsc": "tsc --noEmit", | |
"lint:eslint": "eslint --ext .js,.ts,.tsx .", | |
"lint:prettier": "prettier --check .", | |
"fix": "prettier --write . && eslint --fix --ext .js,.ts,.tsx .", | |
"test": "jest" | |
}, | |
"lint-staged": { | |
"*.{js,ts,tsx}": [ | |
"prettier --write", | |
"eslint --ext .js,.ts,.tsx --fix" | |
] | |
}, | |
"husky": { | |
"hooks": { | |
"pre-commit": "tsc --noEmit && lint-staged && yarn test" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextPage } from "next"; | |
import "../css/tailwind.css"; | |
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | |
const App = ({ | |
Component, | |
pageProps, | |
}: { | |
Component: NextPage; | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
pageProps: any; | |
}) => { | |
return <Component {...pageProps} />; | |
}; | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-env node */ | |
const purgecss = [ | |
"@fullhuman/postcss-purgecss", | |
{ | |
content: ["./components/**/*.js", "./pages/**/*.js"], | |
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | |
defaultExtractor: (content) => content.match(/[\w-/:]+(?<!:)/g) || [], | |
}, | |
]; | |
module.exports = { | |
plugins: [ | |
"postcss-import", | |
"tailwindcss", | |
"autoprefixer", | |
...(process.env.NODE_ENV === "production" ? [purgecss] : []), | |
], | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-env node */ | |
module.exports = { | |
theme: { | |
extend: {}, | |
}, | |
variants: { | |
backgroundColor: ["responsive", "hover", "focus", "active"], | |
}, | |
plugins: [], | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"extends": "./tsconfig.json", | |
"include": [ | |
"**/*.tsx", | |
"**/*.ts", | |
"*.ts", | |
"**/*.js", | |
"*.js", | |
"next-env.d.ts" | |
], | |
"exclude": ["node_modules", "dist", ".next", "out"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"jsx": "react", | |
"allowJs": true, | |
"allowSyntheticDefaultImports": true, | |
"esModuleInterop": true, | |
"noImplicitAny": true, | |
"sourceMap": true, | |
"target": "es5" | |
}, | |
"include": ["**/*.ts", "**/*.tsx"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"allowJs": true, | |
"alwaysStrict": true, | |
"esModuleInterop": true, | |
"forceConsistentCasingInFileNames": true, | |
"isolatedModules": true, | |
"jsx": "preserve", | |
"lib": ["dom", "esnext"], | |
"module": "esnext", | |
"moduleResolution": "node", | |
"noEmit": true, | |
"noFallthroughCasesInSwitch": true, | |
"noUnusedLocals": true, | |
"noUnusedParameters": true, | |
"resolveJsonModule": true, | |
"skipLibCheck": true, | |
"strict": true, | |
"target": "esnext" | |
}, | |
"exclude": ["node_modules"], | |
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment