Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

akagire/eslint-config-p-ts

Repository files navigation

This repository was archived. And eslint-config-p-ts was renamed and moved to appropriate organization. Please don't use this package.

eslint-config-p-ts

This package provides P's base TS .eslintrc as an extensible shared config.

This configure was created from this document. https://github.com/basarat/typescript-book/blob/master/docs/styleguide/styleguide.md

Changed rules from TypeScript books style guide

Naming

[MUST] Use prefix I to interface

Yes, it is useless, but rules is not unnecessary in rules. I think, don't use prefix I is also perfect rule. You can customize it in your project.

Bad

interface MyProps {
  hoge: string;
  fuga: number;
}

Good

interface IMyProps {
  hoge: string;
  fuga: number;
}

Export

[SHOULD] No export default

Please ignore this when needs use default export in framework. (eg Nuxt's middleware)

Bad

class Foo {}
export default Foo;

Good

export class Foo {}

Semicolon

[MUST] Use Semicolons in interfaces

In TypeScript, you can separate interfaces with semicolons, also can use commas too. But modern coding rule is recommended use semicolon.

Bad

interface Hoge {
  huga: string,
  piyo: number,
}

const foo: { bar: string, baz: number } = { bar: 'bar', baz: 0 };

Good

interface Hoge {
  huga: string;
  piyo: number;
}

const foo: { bar: string; baz: number; } = { bar: 'bar', baz: 0 };

Usage

Packaged our JavaScript / TypeScript coding standard.

  1. Install dependencies packages.
yarn add -D eslint-config-p-ts
  1. Add your .eslintrc 's extends section.
extends: ['p-ts']

Please note here has meaning to the position. We prefer put it last or put before prettier.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •