eslint-config-tamia

2018-10-11 admin

eslint-config-tamia是什么

什么是eslint-config-tamia,Tâmia ESLint config

eslint-config-tamia使用教程帮助文档

eslint-config-tamia

Build Status npm

This package provides Tâmia’s .eslintrc as an extensible shared config. Based on eslint-config-airbnb.

Should be used with Prettier, has no own code style rules.

Usage

We export three ESLint configurations:

eslint-config-tamia

Our default export contains all of our ESLint rules, including EcmaScript 6+. It requires eslint.

npm install --save-dev eslint-config-tamia eslint

.eslintrc:

{
  "extends": "tamia"
}

eslint-config-tamia/react

Lints ES6+ but and React. Requires eslint and eslint-plugin-react.

npm install --save-dev eslint-config-tamia eslint-plugin-react eslint

.eslintrc:

{
  "extends": "tamia/react"
}

eslint-config-tamia/legacy

Lints ES5 and below. Only requires eslint.

npm install --save-dev eslint-config-tamia eslint

.eslintrc:

{
  "extends": "tamia/legacy"
}

Code style at a glance

  • Tab indentation.
  • Single-quotes.
  • Semicolons.
  • Declare variables just before their first usage.
  • Multiple variable statements.
  • Make const, not var.
  • Use === and !== over == and !=.
  • Return early.
  • Limit line lengths to 80 chars.
  • Prefer readability over religion.
  • Use ES6.

Example:

function eatFood(food) {
	if (!food.length) {
		return ['No food'];
	}

	return food.map(dish => `No ${dish.toLowerCase()}`);
}

const food = ['Pizza', 'Buger', 'Coffee'];
console.log(eatFood(food));

See ESlint config docs for more information.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-42437.html

文章标题:eslint-config-tamia

回到顶部