Skip to content

Instantly share code, notes, and snippets.

@SanariSan
Last active July 7, 2022 20:25
Show Gist options
  • Save SanariSan/890b90321260821a6e02a6ae4a39dd99 to your computer and use it in GitHub Desktop.
Save SanariSan/890b90321260821a6e02a6ae4a39dd99 to your computer and use it in GitHub Desktop.
Basic Project Configs
.gitignore
.prettierignore
.prettierrc
.prettierrc.eslint
tsconfig-base.json
tsconfig.json
.eslintrc.json
.eslintignore
package.json
Content inside.
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,react,yarn
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,node,react,yarn
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env.production
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### react ###
.DS_*
**/*.backup.*
**/*.back.*
node_modules
*.sublime*
psd
thumb
sketch
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### yarn ###
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
# if you are NOT using Zero-installs, then:
# comment the following lines
!.yarn/cache
# and uncomment the following lines
# .pnp.*
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,react,yarn
*.ignore*
dist*
logs*
*.http
*.env*
!.env.copy
{
// could explicitly define parser here, but leaving default eslint parser (*)
// then override it with needed in "overrides" section
// "parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"env": {
"node": true,
"es2020": true
// "browser": true,
// "jest": true
},
"settings": {
// plugin import, resolving process https://github.com/import-js/eslint-plugin-import#resolvers
"import/resolver": {
// https://github.com/import-js/eslint-plugin-import#importextensions
// use eslint-import-resolver-node only for these extensions https://www.npmjs.com/package/eslint-import-resolver-node
"node": {
"extensions": [".js", ".jsx"],
"ecmaFeatures": {
"jsx": true
}
}
}
},
// plugins (eslint-plugin- <name>) - doing something on side (convert/compute) ;
// exposing sets of rules to apply in "extends" ; exposing individual rules to apply/change in "rules" if have some
"plugins": [
// a lot of useful typescript specific rules https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin
"@typescript-eslint",
// promises rules https://github.com/xjamundx/eslint-plugin-promise
"promise",
// set of useful rules rules https://github.com/sindresorhus/eslint-plugin-unicorn
"unicorn",
// everything about importing https://github.com/import-js/eslint-plugin-import
"import",
// converting local prettier config into set of rules https://github.com/prettier/eslint-plugin-prettier#installation
"prettier"
],
// extends (eslint-config- <name>) - sets of rules from plugins above ; from eslint-config- <name> directly
"extends": [
"airbnb-base",
"eslint:recommended",
// airbnb ts rules (compatibility only, no documented rules to change)
"airbnb-typescript/base",
// setting up resolvers for import/export https://github.com/import-js/eslint-plugin-import#typescript
"plugin:import/recommended",
"plugin:import/typescript",
// ts overall recommended rules https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
"plugin:@typescript-eslint/recommended",
// ts overall recommended rules https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#extension-rules
"plugin:@typescript-eslint/recommended-requiring-type-checking",
// promise recommended rules https://github.com/xjamundx/eslint-plugin-promise#rules
"plugin:promise/recommended",
// another set of useful rules
"plugin:unicorn/recommended",
// disabling all the rules that might conflict with prettier https://github.com/prettier/eslint-config-prettier#installation
"prettier"
],
// rules - place for overridng/setting rules from plugin/config
// *although typescript configs are in separate "overrides" section, these rules work for both js and ts, then some overrided
"rules": {
// ==========================================
// rules:unicorn
// + plugin:unicorn/recommended
// Airbnb prefers functional iteration over arrays, with forEach https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/no-array-for-each.md | https://github.com/airbnb/javascript#iterators--nope
"unicorn/no-array-for-each": "off",
// Enforce correct Error subclassing https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/custom-error-definition.md
"unicorn/custom-error-definition": ["error"],
// Enforce specifying rules to disable in eslint-disable comments https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/no-abusive-eslint-disable.md
"unicorn/no-abusive-eslint-disable": ["warn"],
// Disallow Array#reduce() and Array#reduceRight() https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/no-array-reduce.md
// Warn, because sometimes it's acceptable to use reduce (not only simple operations). Just mark the line and maybe rewrite later.
"unicorn/no-array-reduce": ["warn"],
// Disallow process.exit() https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/no-process-exit.md
// Off because using dashboard, when exit it - exit process
"unicorn/no-process-exit": "off",
// Forbid classes that only have static members https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/no-static-only-class.md
// Off because doesn't work for static methods with private keyword anyways, so won't get misleaded
"unicorn/no-static-only-class": ["off"],
// Uses safe-regex to disallow potentially catastrophic exponential-time regular expressions https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/no-unsafe-regex.md
"unicorn/no-unsafe-regex": ["warn"],
// Prefer .addEventListener() and .removeEventListener() over on-functions https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/prefer-add-event-listener.md
// Already in recommended, but exposed for including packages
"unicorn/prefer-add-event-listener": [
"error",
{
"excludedPackages": ["express", "koa", "sax"]
}
],
// Enforce throwing TypeError in type checking conditions https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/prefer-type-error.md
// Warn, because can conflict with custom errors + no big difference
"unicorn/prefer-type-error": ["warn"],
// Prevent abbreviations https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v38.0.0/docs/rules/prevent-abbreviations.md
// Common abbreviations are known and readable
"unicorn/prevent-abbreviations": "off",
// ==========================================
// rules:prettier
// enable prettier format rules to be check and marked as errors when violated https://github.com/prettier/eslint-plugin-prettier#installation
"prettier/prettier": "error",
// ==========================================
// rules:eslint
// + eslint:recommended
// Don’t use iterators. Prefer JavaScript’s higher-order functions instead of loops like for-in or for-of https://github.com/airbnb/javascript#iterators--nope
// Just warn, because it's more clear to write for-of at first, then refactor into functional solution like forEach, map, etc.
"no-iterator": ["warn"],
"no-restricted-syntax": ["warn"],
// allow void in some cases for @typescript-eslint/no-floating-promises compatibility https://eslint.org/docs/rules/no-void -> https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md#ignorevoid
"no-void": [
"error",
{
"allowAsStatement": true
}
],
// Putting default parameter at last allows function calls to omit optional tail arguments. https://eslint.org/docs/rules/default-param-last
"default-param-last": ["error"],
// Disallow async functions which have no await expression https://eslint.org/docs/rules/require-await
// off because in recommended for @typescript-eslint as @typescript-eslint/require-await
"require-await": ["off"],
// Disallow use of Object.prototypes builtins directly https://eslint.org/docs/rules/no-prototype-builtins
// Too restrictive, writing ugly code to defend against a very unlikely scenario
"no-prototype-builtins": "off",
// Use function hoisting to improve code readability
"no-use-before-define": ["error", { "functions": true, "classes": true, "variables": true }],
// Require return statements to either always or never specify values https://eslint.org/docs/rules/consistent-return
// Too much extra code (return undefined in every void fn) for little profit + ts analysis takes care
"consistent-return": ["off"],
// Disallow redundant return statements https://eslint.org/docs/rules/no-useless-return
// Conflict with TS { Not all code paths return a value.ts(7030) }
// Removing empty return; Don't want to type return undefined; so it's off
"no-useless-return": ["off"],
// Disallow the use of console https://eslint.org/docs/rules/no-console
// When using node console should be allowed
"no-console": ["off"],
// Disallow if statements as the only statement in else blocks https://eslint.org/docs/rules/no-lonely-if
"no-lonely-if": ["error"],
// ==========================================
// rules:import
// + import/recommended (recommended are listed below, since NOT listed on gh page)
// "import/named": "error",
// "import/namespace": "error",
// "import/default": "error",
// "import/export": "error",
// "import/no-named-as-default": "warn",
// "import/no-named-as-default-member": "warn",
// "import/no-duplicates": "warn",
// + plugin:import/typescript (recommended are partially listed below)
// "import/named": 'off',
// Ensures an imported module can be resolved to a module on the local filesystem https://github.com/import-js/eslint-plugin-import/blob/v2.25.2/docs/rules/no-unresolved.md
// Ignoring node:* because these are core node modules, false positive
"import/no-unresolved": ["error", { "ignore": ["node:*"] }],
// Forbid a module from importing a module with a dependency path back to itself https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
"import/no-cycle": ["warn", { "maxDepth": "∞" }],
// Prefer a default export if module exports a single name https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
"import/prefer-default-export": ["off"],
// Forbid default exports https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html | https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md
"import/no-default-export": ["error"],
// ==========================================
// rules:promise
// + plugin:promise/recommended
// ==========================================
// rules:@typescript-eslint minor
// + plugin:@typescript-eslint/recommended
// + plugin:@typescript-eslint/recommended-requiring-type-checking
// Disallow the use of variables before they are defined (extends eslint no-use-before-define) https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-use-before-define.md
"@typescript-eslint/no-use-before-define": [
"error",
{ "functions": true, "classes": true, "variables": true, "typedefs": true }
],
// Requires using either T[] or Array<T> for arrays https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md
"@typescript-eslint/array-type": [
"error",
{
"default": "array-simple"
}
],
// Bans @ts-<directive> comments from being used or requires descriptions after directive https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-ts-comment.md
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-ignore": false,
"ts-nocheck": "allow-with-description",
"ts-check": "allow-with-description",
"ts-expect-error": "allow-with-description",
"minimumDescriptionLength": 10
}
],
// Recommends using @ts-expect-error over @ts-ignore https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md
// Because of rule "@typescript-eslint/ban-ts-comment", ts-ignore can't be used anyway, but with this - getting autofixed if written by mistake
"@typescript-eslint/prefer-ts-expect-error": ["error"],
// Enforces consistent usage of type assertions https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-assertions.md
"@typescript-eslint/consistent-type-assertions": [
"error",
{
"assertionStyle": "as",
"objectLiteralTypeAssertions": "allow"
}
],
// Require a specific member delimiter style for interfaces and type literals https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/member-delimiter-style.md
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
},
"multilineDetection": "brackets"
}
],
// Enforces using a particular method signature syntax https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/method-signature-style.md
// prop: () => {} for functions in objects
"@typescript-eslint/method-signature-style": ["error", "property"],
// Requires expressions of type void to appear in statement position https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-confusing-void-expression.md
"@typescript-eslint/no-confusing-void-expression": [
"error",
{
"ignoreArrowShorthand": false,
"ignoreVoidOperator": false
}
],
// Disallow the delete operator with computed key expressions https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-dynamic-delete.md
"@typescript-eslint/no-dynamic-delete": ["error"],
// Enforces that type arguments will not be used if not required https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md
"@typescript-eslint/no-unnecessary-type-arguments": ["error"],
// Requires that private members are marked as readonly if they're never modified outside of the constructor https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-readonly.md
"@typescript-eslint/prefer-readonly": ["error"],
// Prefer using type parameter when calling Array#reduce instead of casting https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md
"@typescript-eslint/prefer-reduce-type-parameter": ["error"],
// Enforce that this is used when only this type is returned https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-return-this-type.md
"@typescript-eslint/prefer-return-this-type": ["error"],
// Enforce the use of String#startsWith and String#endsWith instead of other equivalent methods of checking substrings https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md
"@typescript-eslint/prefer-string-starts-ends-with": ["error"],
// Enforce template literal expressions to be of string type https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/restrict-template-expressions.md
"@typescript-eslint/restrict-template-expressions": [
"error",
{
"allowNumber": true,
"allowBoolean": true
}
],
// Exhaustiveness checking in switch with union type https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md
"@typescript-eslint/switch-exhaustiveness-check": ["error"],
// ==========================================
// rules:@typescript-eslint major
// naming rules for everything https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
"@typescript-eslint/naming-convention": [
"error",
/**
* lead-trail undercores forbidden (if member is private, it should be
* written in the way user can't acces it, not just marked like "don't call please")
* general style is camelCase
*/
{
"selector": "default",
"format": ["camelCase"],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid"
},
// but for destructured params - do not apply style (you may want to save original look)
{
"selector": "variable",
"modifiers": ["destructured"],
"format": null
},
// for class use PacalCase
{
"selector": "class",
"format": ["PascalCase"]
},
// for funtion parameters allow leading underscore (so it can be just _)
{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
// for const variables that contains lambda/arrow style is default - camelCase
{
"selector": "variable",
"format": ["camelCase"],
"types": ["function"],
"modifiers": ["const"]
},
// for const variables that are exported - style is UPPER_CASE (default values) or PascalCase (Object with fns properties for example)
{
"selector": "variable",
"format": ["UPPER_CASE", "PascalCase"],
"modifiers": ["const", "exported"]
},
// for just const variables style is camelCase or PascalCase (Object with fns properties for example)
{
"selector": "variable",
"format": ["camelCase", "PascalCase"],
"modifiers": ["const"]
},
// for properties and variables that requires quotes - ignore style (http headers and similar)
{
"selector": [
"classProperty",
"objectLiteralProperty",
"typeProperty",
"classMethod",
"objectLiteralMethod",
"typeMethod",
"accessor",
"enumMember"
],
"format": null,
"modifiers": ["requiresQuotes"]
},
// for interfaces add I before name
{
"selector": "interface",
"format": ["PascalCase"],
"prefix": ["I"]
},
// for types add T before name
{
"selector": "typeAlias",
"format": ["PascalCase"],
"prefix": ["T"]
},
// for types' generic params make it start with T (or be just T), type TMyType<T/Tsmth> = Array<T/Tsmth>
{
"selector": "typeParameter",
"format": ["PascalCase"],
"prefix": ["T"]
},
// for enum - style is UPPER_CASE with prefix E
{
"selector": ["enum"],
"format": ["UPPER_CASE"],
"prefix": ["E"]
},
// for enum members - style is UPPER_CASE
{
"selector": ["enumMember"],
"format": ["UPPER_CASE"]
}
],
// Disallow usage of the any type https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-explicit-any.md
"@typescript-eslint/no-explicit-any": ["warn"],
// TS 3.8+ Enforces consistent usage of type exports https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-exports.md
"@typescript-eslint/consistent-type-exports": ["error"],
// TS 3.8+ Enforces consistent usage of type imports https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-imports.md
// Conflict with ide imports autocompletion (ctrl+space), but auto-fixes on save
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"disallowTypeAnnotations": true
}
],
// Require explicit return types on functions and class methods https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
// Currently off, relying on type inference ; ALWAYS off for js files in "overrides"
"@typescript-eslint/explicit-function-return-type": [
"off",
{
"allowExpressions": false,
"allowTypedFunctionExpressions": true,
"allowHigherOrderFunctions": true,
"allowDirectConstAssertionInArrowFunctions": true,
"allowConciseArrowFunctionExpressionsStartingWithVoid": false
}
],
// Require explicit return and argument types on exported functions' and classes' public class methods https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md
// Currently off, relying on type inference ; ALWAYS off for js files in "overrides"
"@typescript-eslint/explicit-module-boundary-types": [
"off",
{
"allowArgumentsExplicitlyTypedAsAny": false,
"allowDirectConstAssertionInArrowFunctions": true,
"allowedNames": [],
"allowHigherOrderFunctions": true,
"allowTypedFunctionExpressions": true
}
],
// Requires that .toString() is only called on objects which provide useful information when stringified https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-base-to-string.md
"@typescript-eslint/no-base-to-string": ["error"],
// Requires Promise-like values to be handled appropriately https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md
"@typescript-eslint/no-floating-promises": [
"error",
{
"ignoreVoid": true,
"ignoreIIFE": false
}
],
// Disallow the void operator except when used to discard a value https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-meaningless-void-operator.md
"@typescript-eslint/no-meaningless-void-operator": [
"error",
{
"checkNever": false
}
],
// Disallow the use of custom TypeScript modules and namespaces https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-namespace.md
// todo: rewrite errors core type file, then change to "error"
"@typescript-eslint/no-namespace": "warn",
// Disallow the use of parameter properties in class constructors https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-parameter-properties.md
"@typescript-eslint/no-parameter-properties": ["error"],
// Prevents conditionals where the type is always truthy or always falsy https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-condition.md
"@typescript-eslint/no-unnecessary-condition": [
"warn",
{
"allowConstantLoopConditions": true
}
],
// Warns if a type assertion does not change the type of an expression https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md
// enabled by default, but might be useful to off later
"@typescript-eslint/no-unnecessary-type-assertion": ["warn"],
// Disallows the use of require statements except in import statements https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-var-requires.mds
"@typescript-eslint/no-var-requires": ["warn"],
// Require that all enum members be literal values to prevent unintended enum member name shadow issues https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-literal-enum-member.md
"@typescript-eslint/prefer-literal-enum-member": [
"error",
{
"allowBitwiseExpressions": true
}
],
// Requires that function parameters are typed as readonly to prevent accidental mutation of inputs https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md
// Off for Express mutation style compatibility
"@typescript-eslint/prefer-readonly-parameter-types": [
"off",
{
"checkParameterProperties": true,
"ignoreInferredTypes": true,
"treatMethodsAsReadonly": true
}
],
// Restricts the types allowed in boolean expressions https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md
"@typescript-eslint/strict-boolean-expressions": [
"error",
{
// str !== ''
"allowString": false,
// num !== 0
"allowNumber": false,
// object ?? false
"allowNullableObject": true,
"allowNullableBoolean": false,
"allowNullableString": false,
"allowNullableNumber": false,
"allowAny": false,
"allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing": false
}
],
// "error" by default, "warn" during refactoring to first fix all logical mistakes and only then bad typings
"@typescript-eslint/no-unsafe-member-access": ["warn"],
"@typescript-eslint/no-unsafe-call": ["warn"],
"@typescript-eslint/no-unsafe-assignment": ["warn"]
},
"overrides": [
{
// disable rules for js files
"files": ["**/*.{js,jsx}"],
"rules": {
"@typescript-eslint/explicit-function-return-type": ["off"],
"@typescript-eslint/explicit-module-boundary-types": ["off"],
"@typescript-eslint/no-var-requires": ["off"]
}
},
// TYPESCRIPT PARSING SETUP
{
"files": ["**/*.{ts,tsx}"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
// ts parser should read following configs file
"project": "./tsconfig.json"
},
"env": {
"node": true,
"es2020": true
// "browser": true,
// "jest": true
},
"settings": {
// plugin import, resolving process https://github.com/import-js/eslint-plugin-import#resolvers
"import/resolver": {
// use eslint-import-resolver-typescript https://github.com/alexgorbatchev/eslint-import-resolver-typescript
"typescript": {
// ts resolver, when used, should read following configs file
"project": "./tsconfig.json"
}
}
},
"rules": {
// These 2 rules extend the base eslint/default-param-last rule. It adds support for optional parameters. https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/default-param-last.md
"default-param-last": "off",
"@typescript-eslint/default-param-last": ["error"]
}
}
]
}
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,react,yarn
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,node,react,yarn
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env.production
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### react ###
.DS_*
**/*.backup.*
**/*.back.*
node_modules
*.sublime*
psd
thumb
sketch
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### yarn ###
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
# if you are NOT using Zero-installs, then:
# comment the following lines
!.yarn/cache
# and uncomment the following lines
# .pnp.*
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,react,yarn
*.ignore*
dist*
logs*
*.http
*.env*
!.env.copy
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,react,yarn
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,node,react,yarn
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
.env.production
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### react ###
.DS_*
**/*.backup.*
**/*.back.*
node_modules
*.sublime*
psd
thumb
sketch
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### yarn ###
# https://yarnpkg.com/advanced/qa#which-files-should-be-gitignored
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
# if you are NOT using Zero-installs, then:
# comment the following lines
!.yarn/cache
# and uncomment the following lines
# .pnp.*
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,node,react,yarn
*.ignore*
dist*
logs*
*.http
*.env*
!.env.copy
{
"printWidth": 100,
"tabWidth": 4,
"useTabs": true,
"semi": true,
"singleQuote": false,
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"proseWrap": "always",
"quoteProps": "as-needed",
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto"
}
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always",
"proseWrap": "never",
"quoteProps": "as-needed",
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto"
}
image-downloader
request
request-promise
puppeteer
chokidar - fs watch
diff - difference founder
md5
node-machine-id
vk-io
telegraf/telegram
thirty-two - base32 good encode/decode
totp-generator
pdf417-generator - draw barcode
canvas
colors
https-proxy-agent
jsonfile
steam-totp
{
"name": "name",
"version": "1.0.0",
"main": "index.js",
"author": "SanariSan <SanariSan@users.noreply.github.com>",
"license": "MIT",
"scripts": {
"---tips": "---------------------------------------------------------------",
"------start": "accepts -linux/-win, always triggers build, which is for pre/post build compatibility",
"------build": "accepts -linux/-win",
"------launch": "accepts -dev/-prod",
"------prebuild-skip": "swap between true/false to turn skip on/off",
"---general control": "---------------------------------------------------------------",
"start": "yarn start-linux",
"build": "yarn build-linux",
"launch": "yarn launch-dev",
"prebuild-skip": "true",
"prebuild": "yarn prebuild-skip || (yarn format && yarn lint)",
"---start os": "---------------------------------------------------------------",
"start-linux": "yarn build && yarn copy-deps && yarn cli-wipe-linux && yarn launch",
"start-ts-linux": "yarn cli-wipe-linux && node ./node_modules/ts-node/dist/bin.js ./src/app.ts",
"start-win": "yarn build && yarn copy-deps && yarn cli-wipe-win && yarn launch",
"start-ts-win": "yarn cli-wipe-win && node ./node_modules/ts-node/dist/bin.js ./src/app.ts",
"---start-general": "---------------------------------------------------------------",
"start-prod": "yarn build && yarn launch-prod",
"---build os": "---------------------------------------------------------------",
"build-linux": "yarn build-drop-linux && tsc",
"build-drop-linux": "rm -rf ./dist",
"build-win": "yarn build-drop-win && tsc",
"build-drop-win": "del /f /s /q \"./dist\"",
"---launch general": "---------------------------------------------------------------",
"launch-prod": "./node_modules/cross-env/src/bin/cross-env.js NODE_ENV=production node -r dotenv/config ./dist/app.js",
"launch-dev": "./node_modules/cross-env/src/bin/cross-env.js NODE_ENV=development node -r dotenv/config ./dist/app.js",
"---prepare fs general": "---------------------------------------------------------------",
"copy-deps": "yarn copy-config",
"copy-config": "true",
"---cli os": "---------------------------------------------------------------",
"cli-wipe-linux": "printf '\\033c\\033[3J'",
"cli-wipe-scroll-linux": "printf '\\033[H\\033[2J'",
"cli-wipe-win": "todo: test when on windows",
"---additional": "---------------------------------------------------------------",
"format": "./node_modules/prettier/bin-prettier.js -w --config ./.prettierrc .",
"lint": "./node_modules/.bin/eslint --ext .ts .",
"lint-quiet": "./node_modules/.bin/eslint --quiet --ext .ts .",
"lint-fix": "./node_modules/.bin/eslint --fix --ext .ts .",
"madge-json": "node ./node_modules/madge/bin/cli.js -c -j --ts-config ./tsconfig.json ./dist/",
"madge-pic": "node ./node_modules/madge/bin/cli.js -c -j -i ./dep.svg --ts-config ./tsconfig.json ./dist/"
},
"configurationDefaults": {
"---here can override": "any VSCODE options except those from application or machine scopes"
},
"dependencies": {
"cross-env": "^7.0.3",
"dotenv": "^12.0.3",
},
"devDependencies": {
"@types/node": "^16.11.0",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"eslint": "^7.2.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^14.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.1.1",
"eslint-plugin-unicorn": "^38.0.0",
"madge": "^5.0.1",
"prettier": "^2.4.1",
"ts-node": "^10.3.0",
"typescript": "^4.5.2"
}
}
{
"compilerOptions": {
"noImplicitAny": false,
"noImplicitThis": false,
"noImplicitReturns": true,
"strict": true,
"alwaysStrict": true,
"skipLibCheck": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noFallthroughCasesInSwitch": true,
"removeComments": true,
"sourceMap": false
}
}
{
"extends": "./tsconfig-base.json",
"compilerOptions": {
//specific
"target": "ES2020",
"module": "CommonJS",
"moduleResolution": "node",
//static
"resolveJsonModule": true,
"allowJs": false,
"forceConsistentCasingInFileNames": true,
"rootDir": "src",
"outDir": "dist",
"declaration": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"pretty": true,
//
// - optional
//
// "lib": ["dom", "dom.iterable", "esnext"],
// "noEmit": true,
// "jsx": "react",
// "isolatedModules": true
//
// - typeorm
//
// "emitDecoratorMetadata": true,
// "experimentalDecorators": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "ignore/**/*"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment