# @iceworks/spec

> Easy to use eslint/stylelint/prettier/commitlint in rax, ice and react project.

Latest version **1.6.0** (published 2022-03-09) · 0 weekly downloads

## Install

```sh
npm install @iceworks/spec
pnpm add @iceworks/spec
yarn add @iceworks/spec
bun add @iceworks/spec
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.6.0 |
| Published | 2022-03-09 |
| First published | 2020-10-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 19 |
| Unpacked size | 16.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 60 |
| Maintainers | yuanyan, sobear, empireo, alvinhui, rax-publisher, luhengchang228, fyangstudio |

## Links

- npm: https://www.npmjs.com/package/@iceworks/spec
- Repository: https://github.com/ice-lab/spec
- Homepage: https://github.com/ice-lab/spec#readme
- Issues: https://github.com/ice-lab/spec/issues
- npm.io page: https://npm.io/package/@iceworks/spec

## Dependencies (19)

- [json5](https://npm.io/package/json5.md) ^2.2.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.16.0
- [require-all](https://npm.io/package/require-all.md) ^3.0.0
- [stylelint-scss](https://npm.io/package/stylelint-scss.md) ^3.18.0
- [eslint-config-ali](https://npm.io/package/eslint-config-ali.md) ^13.0.0
- [eslint-plugin-vue](https://npm.io/package/eslint-plugin-vue.md) ^7.3.0
- [vue-eslint-parser](https://npm.io/package/vue-eslint-parser.md) ^7.2.0
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.16.0
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.21.5
- [@babel/eslint-parser](https://npm.io/package/@babel/eslint-parser.md) ^7.16.3
- [eslint-plugin-import](https://npm.io/package/eslint-plugin-import.md) ^2.22.1
- [stylelint-config-ali](https://npm.io/package/stylelint-config-ali.md) ^0.3.4
- [commitlint-config-ali](https://npm.io/package/commitlint-config-ali.md) ^0.1.0
- [eslint-plugin-jsx-plus](https://npm.io/package/eslint-plugin-jsx-plus.md) ^0.1.0
- [@typescript-eslint/parser](https://npm.io/package/@typescript-eslint/parser.md) ^5.0.0
- [eslint-plugin-react-hooks](https://npm.io/package/eslint-plugin-react-hooks.md) ^4.2.0
- [@typescript-eslint/eslint-plugin](https://npm.io/package/@typescript-eslint/eslint-plugin.md) ^5.0.0
- [@iceworks/eslint-plugin-best-practices](https://npm.io/package/@iceworks/eslint-plugin-best-practices.md) ^0.2.0
- [eslint-plugin-rax-compile-time-miniapp](https://npm.io/package/eslint-plugin-rax-compile-time-miniapp.md) ^1.0.0

## Recent versions

- 1.6.0 (latest) — 2022-03-09
- 1.4.0-0 (beta) — 2021-04-27
- 1.5.0 — 2021-12-21
- 1.4.2 — 2021-09-22
- 1.4.1 — 2021-09-02
- 1.4.0 — 2021-09-01
- 1.3.2 — 2021-05-07
- 1.3.1 — 2021-04-25
- 1.3.0 — 2021-04-22
- 1.2.0 — 2021-03-23
- 1.1.0 — 2020-12-17
- 1.0.3 — 2020-11-11
- 1.0.2 — 2020-11-05
- 1.0.2-0 — 2020-11-05
- 1.0.1 — 2020-11-05
- … 3 more at https://npm.io/package/@iceworks/spec/versions

## README

# @iceworks/spec

Easy to use **eslint**(support TypeScript) / **stylelint** / **prettier** / **commitlint** in [rax](https://rax.js.org/), [ice](https://ice.work/) and react project. And spec means specification.

## Install

```bash
$ npm i --save-dev @iceworks/spec eslint stylelint prettier @commitlint/cli
```

PS: You don't need to install other eslint plugins and parsers.

## Usage

### ESLint

#### 1. Create configuration file

First create a `.eslintrc.js` file. Then edit your config.

#### 2. Update config

##### JavaScript + [rax](https://rax.js.org/), [ice](https://ice.work/) and react

[rules](https://github.com/ice-lab/spec/tree/master/packages/spec/src/eslint/react.js) base on [eslint-config-ali](https://www.npmjs.com/package/eslint-config-ali) and [@iceworks/eslint-plugin-best-practices](https://www.npmjs.com/package/@iceworks/eslint-plugin-best-practices).

```js
// .eslintrc.js
const { getESLintConfig } = require('@iceworks/spec');

// getESLintConfig(rule: 'common'|'rax'|'react'|'vue' , customConfig?);
module.exports = getESLintConfig('common');
```

##### TypeScript + [rax](https://rax.js.org/), [ice](https://ice.work/) and react

[rules](https://github.com/ice-lab/spec/tree/master/packages/spec/src/eslint/react-ts.js) base on [eslint-config-ali](https://www.npmjs.com/package/eslint-config-ali) and [@iceworks/eslint-plugin-best-practices](https://www.npmjs.com/package/@iceworks/eslint-plugin-best-practices).

```js
// .eslintrc.js
const { getESLintConfig } = require('@iceworks/spec');

// getESLintConfig(rule: 'common-ts'|'rax-ts'|'react-ts'|'vue-ts', customConfig?);
module.exports = getESLintConfig('common-ts');
```

### stylelint

#### 1. Create configuration file

First create a `.stylelintrc.js` file. Then edit your config.

#### 2. Update config

[rules](https://github.com/ice-lab/spec/tree/master/packages/spec/src/stylelint/react.js) base on [stylelint-config-ali](https://www.npmjs.com/package/stylelint-config-ali)

```js
// .stylelintrc.js
const { getStylelintConfig } = require('@iceworks/spec');

// getStylelintConfig(rule: 'common'|'rax'|'react'|'vue', customConfig?);
module.exports = getStylelintConfig('react');
```

### prettier [rules](https://github.com/ice-lab/spec/tree/master/packages/spec/src/prettier/react.js)

#### 1. Create configuration file

First create a `.prettierrc.js` file. Then edit your config.

#### 2. Update config

```js
// .prettierrc.js
const { getPrettierConfig } = require('@iceworks/spec');

// getPrettierConfig(rule: 'common'|'rax'|'react'|'vue', customConfig?);
module.exports = getPrettierConfig('react');
```

### commitlint

#### 1. Create configuration file

First create a `.commitlintrc.js` file. Then edit your config.

#### 2. Update config

[rules](https://github.com/ice-lab/spec/tree/master/packages/spec/src/commitlint/react.js) base on [commitlint-config-ali](https://www.npmjs.com/package/commitlint-config-ali)

```js
// .commitlintrc.js
const { getCommitlintConfig } = require('@iceworks/spec');

// getCommitlintConfig(rule: 'common'|'rax'|'react'|'vue', customConfig?);
module.exports = getCommitlintConfig('react');
```

## FAQ

### Custom config

```js
// .eslintrc.js
const { getESLintConfig } = require('@iceworks/spec');

// getESLintConfig(rule: 'common'|'rax'|'react'|'vue', customConfig?);
module.exports = getESLintConfig('rax', {
  // custom config it will merge into main config
  rules: {
    // ...
  },
});
```

### package.json scripts

Add `scripts` in your `package.json`, example:

```json
"scripts": {
  "lint": "npm run eslint && npm run stylelint",
  "eslint": "eslint --cache --ext .js,.jsx,.ts,.tsx ./",
  "stylelint": "stylelint ./**/*.scss",
  "prettier": "prettier **/* --write"
}
```

Then use `npm run lint` check your project, ues `npm run prettier` update your code.

### Git hooks

To lint commits before they are created you can use Husky's Git hook.

Install in your project `npm install husky --save-dev` or `yarn add -D husky`.

After that, we recommend you to see [husky docs](https://www.npmjs.com/package/husky), then create "`commit-msg`" and "`pre-commit`" config.

### Update from @ice/spec

If you are using [@ice/spec](https://www.npmjs.com/package/@ice/spec) in your project, we recommend use `@iceworks/spec` to get better maintainability and faster response to lint rules support.

Based on `@iceworks/spec`'s simple API you can quickly migrate your project, install and update your lint config file, the mission is completed 😁.

### Error: Cannot find module 'eslint-plugin-foo'

Eslint is not yet supported having plugins as dependencies in shareable config. [issue](https://github.com/eslint/eslint/issues/3458). As a temporary solution, you need add the plugin to devDependencies in your project, like `npm i --save-dev eslint-plugin-jsx-a11y`.

### Error: The file does not match your project config

TypeScript project run lint file when see this error, you can update your `tsconfig.json`.

update `src/*` to `src/**/*`:

```json
{
  "include": ["src/**/*"]
}
```

[CHANGELOG](https://github.com/ice-lab/spec/blob/master/CHANGELOG.md)

Enjoy!

---
_Source: https://npm.io/package/@iceworks/spec · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
