Skip to content

Instantly share code, notes, and snippets.

@leader22

leader22/.eslintrc.js

Last active Apr 28, 2020
Embed
What would you like to do?
Preact x TypeScript x Babel x webpack x ESLint
module.exports = {
env: {
es6: true,
browser: true,
jasmine: true,
node: true
},
settings: {
react: {
pragma: "h",
version: "detect"
}
},
parser: "@typescript-eslint/parser",
parserOptions: {
sourceType: "module",
ecmaFeatures: {
jsx: true
}
},
plugins: ["@typescript-eslint", "react", "react-hooks"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
"prettier/@typescript-eslint",
"prettier/react"
],
rules: {
"no-console": "off",
"no-debugger": "off",
"no-else-return": "error",
"no-self-compare": "error",
"no-void": "error",
"no-var": "error",
"no-lonely-if": "error",
"prefer-const": "error",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{ accessibility: "no-public" }
],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-use-before-define": "off",
"react/no-unknown-property": [
"error",
{ ignore: ["class"] }
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error"
}
};
{
"devDependencies": {
"@babel/core": "^7.8.6",
"@babel/plugin-transform-react-jsx": "^7.9.4",
"@babel/preset-react": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"babel-loader": "^8.0.6",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^2.5.0",
"prettier": "^1.19.1",
"typescript": "^3.8.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
}
}
{
compilerOptions: {
target: esnext,
moduleResolution: node,
esModuleInterop: true,
jsx: react,
jsxFactory: h,
module: commonjs,
removeComments: true,
resolveJsonModule: true,
strict: true,
noUnusedLocals: true,
noUnusedParameters: true,
noImplicitReturns: true,
noFallthroughCasesInSwitch: true
},
include: [
./src
],
exclude: [
./node_modules
]
}
module.exports = () => ({
// ...
module: {
rules: [
{
test: /\.tsx?$/,
exclude: [/node_modules/],
use: [
{
loader: "babel-loader",
options: {
plugins: [
[
"@babel/plugin-transform-react-jsx",
{ pragma: "h", pragmaFrag: "Fragment" }
]
],
presets: [["@babel/typescript", { jsxPragma: "h" }]]
}
}
]
}
]
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.