Socket
Book a DemoInstallSign in
Socket

@beyondessential/eslint-config-ts

Package Overview
Dependencies
Maintainers
7
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@beyondessential/eslint-config-ts

Beyond Essential System's ESLint config for TypeScript/React.js

2.0.0
latest
Source
npmnpm
Version published
Maintainers
7
Created
Source

@beyondessential/eslint-config-ts

TypeScript/React.js style guide as as shareable ESLint configuration

This package defines Beyond Essential System's style guide for TypeScript/React.js projects. It extends our JavaScript/React.js style guide, with additional TypeScript-specific rules.

Installation

yarn add -D @beyondessential/eslint-config-ts

Usage

You need to extend this package in your ESLint configuration:

{
  "extends": "@beyondessential/ts"
}

⚠️ If you use a TS configuration file other than the default (tsconfig.json under the project's root), you need to specify its path:

{
  "parserOptions": {
    "project": "ts/tsconfig.dev.json"
  }
}

⚠️ If you get the following error:

Configuration for rule "@typescript-eslint/indent" is invalid

it is a known eslint-config-airbnb-typescript issue, see that link for possible solutions.

Maintenance

Please be mindful of this package's twin sibling, @beyondessential/eslint-config-ts: you may want to reflect any common rule/dependency updates in that package too.

Publishing

  • Checkout the latest code: git fetch && git checkout master
  • Commit your changes in a new branch
  • ⚠️ Don't forget to also update the package version: npm version # < patch || minor || major >
  • Create a pull request against master

After your PR is approved and merged:

git fetch && git checkout master && git pull
npm login
npm publish --access public

Style guide

This style guide is a combination of:

Changes

RuleAirbnbBESComment
@typescript-eslint/explicit-function-return-typeerroroffTypeScript can accurately infer return types. Explicit return types should be used only when they use a project-specific type which is not inferred automatically
@typescript-eslint/explicit-module-boundary-typeserroroffSimilarly to @typescript-eslint/explicit-function-return-type
@typescript-eslint/no-use-before-defineerroroff
@typescript-eslint/comma-dangleerroroffPrettier and eslint seem to have conflicting errors on when to apply this rule, so disabling eslint in favor of prettier
@typescript-eslint/no-empty-interfaceerrorAllow single extendsIn some circumstances it can be useful to define a type that extends a single generic interface with concrete types
@typescript-eslint/lines-between-class-memberserroroffThis rule leads to extraneously long classes in some cases. Prefer to leave it up to developer discretion
@typescript-eslint/explicit-member-accessibilityoffRequire explicit accessEnforcing explicit accessibility modifiers helps encourage better encapsulation practices
class-methods-use-thiserroroffThis rule was made to encourage the usage of static methods where possible. However, there are valid reasons to not use a static method, even if this is not required (eg testability, inheritance, using functionality via the instance rather than the class).
import/ordererrorwarn
import/prefer-default-exporterroroff
no-await-in-looperroroffThis is a common syntax for async operations that must be performed serially.
no-continueerroroffIn most cases it is preferable to break our functions into smaller ones than use continue. However, sometimes it serves as a compromise between performance and readability. Also, it is useful in refactoring big functions in legacy code.
no-pluspluserroroffA standard in for loops, which we allow.
no-prototype-builtinserroroff
no-restricted-globalserroroff
no-restricted-syntaxRestrict for...of loopsAllow for...of loops
radixerroroffIn the vast majority of the cases we just use the default radix of 10. There is one case where this rule would be useful: array.map(parseInt), where radix will be wrongly set to the array index of each iteration. Unfortunately this rule's implementation does not cover this scenario.
react/forbid-prop-typesForbid array, objectAllow array, object
react/jsx-filename-extensionAllow only .jsxoff
react/jsx-one-expression-per-line['error', { allow: 'single-child' }]off
react/jsx-props-no-spreadingerroroff
react/no-did-update-set-stateerroroff

Additions

Enforce prettier formatting

Rule: prettier/prettier: error Configuration:

{
  "arrowParens": "avoid",
  "printWidth": 100,
  "singleQuote": true,
  "trailingComma": "all"
}

Keywords

eslint

FAQs

Package last updated on 20 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.