Skip to content

Instantly share code, notes, and snippets.

@kabiiir23
Last active August 18, 2021 05:34
Show Gist options
  • Save kabiiir23/26c73156416d026232e47abf908d1267 to your computer and use it in GitHub Desktop.
Save kabiiir23/26c73156416d026232e47abf908d1267 to your computer and use it in GitHub Desktop.
Typescript + ESLint + Airbnb + Prettier + CSpell
{
"version": "0.1",
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json",
"language": "en",
"words": [
"bitjson",
"bitauth",
"cimg",
"circleci",
"codecov",
"commitlint",
"dependabot",
"editorconfig",
"esnext",
"execa",
"exponentiate",
"globby",
"libauth",
"mkdir",
"prettierignore",
"sandboxed",
"transpiled",
"typedoc",
"untracked"
],
"flagWords": [],
"ignorePaths": [
"package.json",
"package-lock.json",
"yarn.lock",
"tsconfig.json",
"node_modules/**"
]
}
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": "./tsconfig.json" },
"env": { "es6": true },
"ignorePatterns": ["node_modules", "build", "coverage"],
"plugins": ["import", "eslint-comments", "functional"],
"extends": [
"airbnb-typescript-prettier",
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"plugin:functional/lite",
"prettier",
"prettier/@typescript-eslint"
],
"globals": { "BigInt": true, "console": true, "WebAssembly": true },
"rules": {
"no-console": "off",
"no-irregular-whitespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"functional/prefer-readonly-type": "off",
"eslint-comments/disable-enable-pair": [
"error",
{ "allowWholeFile": true }
],
"eslint-comments/no-unused-disable": "error",
"import/order": [
"error",
{ "newlines-between": "always", "alphabetize": { "order": "asc" } }
],
"prettier/prettier": "warn", // change it to off if you don't want the wiggly lines.
"import/prefer-default-export": "off",
"sort-imports": [
"error",
{ "ignoreDeclarationSort": true, "ignoreCase": true }
]
}
}
Install necessary packages using yarn:
yarn add -D eslint eslint-config-airbnb-typescript-prettier\
eslint-config-prettier eslint-plugin-eslint-comments\
eslint-plugin-functional eslint-plugin-import eslint-plugin-jsx-a11y\
eslint-plugin-react eslint-plugin-react-hooks
/* .eslintrc.json */
{
"env": {
"browser": true,
"node": true
},
"extends": [
"plugin:react/recommended",
"airbnb-typescript-prettier",
"eslint:recommended"
// "plugin:eslint-comments/recommended",
// "plugin:@typescript-eslint/recommended",
// "plugin:import/typescript",
// "plugin:functional/lite",
// "prettier",
// "prettier/@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["node_modules", "lotties", ".next", "*.js"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint",
"import",
"eslint-comments",
"functional"
],
"rules": {
"react/jsx-one-expression-per-line": "off",
"react/jsx-props-no-spreading": "off",
"react/no-array-index-key": "off",
"react-hooks/exhaustive-deps": "off",
"react/react-in-jsx-scope": "off",
"react/self-closing-comp": "warn",
"react/require-default-props": "off",
"react/button-has-type": "warn",
"react/jsx-filename-extension": [
1,
{ "extensions": [".js", ".jsx", ".tsx"] }
],
"jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/no-static-element-interactions": "warn",
"no-nested-ternary": "off",
"no-irregular-whitespace": "off",
"no-unused-vars": "warn",
"no-use-before-define": "off",
"no-console": "off",
"no-shadow": "off",
"camelcase": "warn",
"linebreak-style": ["off", "windows"],
"import/extensions": 0,
"import/no-unresolved": 0,
"object-curly-newline": "off",
"jsx-quotes": ["warn", "prefer-single"],
"consistent-return": "off",
"no-underscore-dangle": "off",
"no-unused-expressions": "off",
"no-else-return": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/ban-ts-comment": "off",
"functional/prefer-readonly-type": "off",
"functional/no-let": "off",
"functional/no-throw-statement": "off",
"functional/no-return-void": "off",
"functional/no-class": "off",
"functional/immutable-data": "warn",
"eslint-comments/disable-enable-pair": [
"error",
{ "allowWholeFile": true }
],
"eslint-comments/no-unused-disable": "error",
"import/order": [
"error",
{ "newlines-between": "always", "alphabetize": { "order": "asc" } }
],
"import/prefer-default-export": "off",
"import/no-mutable-exports": "off",
"sort-imports": [
"error",
{ "ignoreDeclarationSort": true, "ignoreCase": true }
],
"prettier/prettier": "off"
}
}
{
"arrowParens": "always",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxSingleQuote": true,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"printWidth": 80,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": true
}
Install using yarn:
yarn add -D eslint-config-airbnb-typescript-prettier eslint-config-prettier eslint-plugin-eslint-comments eslint-plugin-functional eslint-plugin-import
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"cspell": "^4.1.0",
"eslint": "^7.30.0",
"eslint-config-airbnb-typescript-prettier": "^4.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^3.0.2",
"eslint-plugin-import": "^2.22.0",
"prettier": "^2.3.2",
"ts-node": "^9.0.0",
"typedoc": "^0.19.0",
"typescript": "^4.3.5",
"@types/node": "^16.3.0"
{
"extends": "./tsconfig.paths.json",
"compilerOptions": {
"incremental": true,
"target": "ES2020",
"outDir": "build/main",
"rootDir": "src",
"moduleResolution": "node",
"module": "commonjs",
"lib": ["ESNext"],
"types": ["node"],
"typeRoots": ["node_modules/@types", "src/types"],
"declaration": true,
"inlineSourceMap": true,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"resolveJsonModule": true /* Include modules imported with .json extension. */,
// "strict": true /* Enable all strict type-checking options. */,
/* Strict Type-Checking Options */
// "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
// "strictNullChecks": true /* Enable strict null checks. */,
// "strictFunctionTypes": true /* Enable strict checking of function types. */,
// "strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */,
// "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
/* Additional Checks */
"noUnusedLocals": false /* Report errors on unused locals. */,
"noUnusedParameters": false /* Report errors on unused parameters. */,
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
/* Debugging Options */
"traceResolution": false /* Report module resolution log messages. */,
"listEmittedFiles": false /* Print names of generated files part of the compilation. */,
"listFiles": false /* Print names of files part of the compilation. */,
"pretty": true /* Stylize errors and messages using color and context. */
/* Experimental Options */
// "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
// "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
},
"include": ["src/**/*.ts"],
"exclude": [
"node_modules/**",
".vscode/**/*",
".github/**/*",
".circleci/**/*"
],
"compileOnSave": false,
"ts-node": {
"require": ["tsconfig-paths/register"]
}
}
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@libs/*": ["src/lib/*"]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment