Skip to content

Commit

Permalink
feat: restart @ice/spec and update version to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
天漾 committed Nov 21, 2024
1 parent 9865b97 commit 2572597
Show file tree
Hide file tree
Showing 80 changed files with 9,600 additions and 593 deletions.
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

17 changes: 0 additions & 17 deletions .eslintrc.js

This file was deleted.

13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ es/
lib/
dist/
build/
esm/
es2017/
coverage/
node_modules/
examples/test
.idea/
.history/
packages/**/lib/
packages/**/dist/
packages/**/build/
packages/**/coverage/
packages/**/node_modules/
packages/*/lib/
packages/*/dist/
packages/*/build/
packages/*/coverage/

package-lock.json
yarn.lock
yarn.lock
3 changes: 1 addition & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
#npx --no-install commitlint --edit "$1"
4 changes: 1 addition & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint && npm run test
lint-staged
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
4 changes: 2 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { getPrettierConfig } = require('./packages/spec/src/');
import { config } from '@ice/spec/prettier';

module.exports = getPrettierConfig('react');
export default config;
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# @iceworks/spec
# @ice/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.
Easy to use **eslint**(support TypeScript) / **stylelint** / **prettier** / **commitlint** in [ice](https://ice.work/) and react project. And spec means specification.

## Install

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

PS: You don't need to install other eslint plugins and parsers.
Expand All @@ -14,20 +14,21 @@ PS: You don't need to install other eslint plugins and parsers.

### ESLint

> NOTE: from @ice/spec 2.0.0, it's requires eslint >= 8.(support flat config)
#### 1. Create configuration file

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

#### 2. Update config

[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');
// eslint.config.js
import { getESLintConfig } from '@ice/spec/eslint';

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

### stylelint
Expand All @@ -42,7 +43,7 @@ First create a `.stylelintrc.js` file. Then edit your config.

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

// getStylelintConfig(rule: 'common'|'rax'|'react'|'vue', customConfig?);
module.exports = getStylelintConfig('react');
Expand All @@ -58,10 +59,10 @@ First create a `.prettierrc.js` file. Then edit your config.

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

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

### commitlint
Expand Down Expand Up @@ -101,7 +102,7 @@ module.exports = getESLintConfig('rax', {

### package.json scripts

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

```json
"scripts": {
Expand All @@ -126,7 +127,7 @@ After that, we recommend you to see [husky docs](https://www.npmjs.com/package/h

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 😁.
Based on `@iceworks/spec`'s simple API you can quickly migrate your project, install and update your lint config file, the mission is completed 😁.

## Develop

Expand Down
7 changes: 4 additions & 3 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { getCommitlintConfig } = require('./packages/spec/src/');

module.exports = getCommitlintConfig('react');
// const { getCommitlintConfig } = require('./packages/spec/src/');
//
// module.exports = getCommitlintConfig('react');
export default {};
11 changes: 11 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import eslint from '@ice/spec/eslint';

// script: eslint --ext .js,.jsx,.tsx,.ts ./ --resolve-plugins-relative-to ./packages/spec
export default [
...eslint.getConfig({
preset: 'pkg',
}),
{
ignores: ['examples/**'],
},
];
3 changes: 3 additions & 0 deletions examples/common/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslint from '@ice/spec/eslint';

export default eslint.getConfig();
8 changes: 8 additions & 0 deletions examples/common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@ice/spec-example-common",
"version": "0.0.1",
"private": true,
"devDependencies": {
"@ice/spec": "workspace:*"
}
}
File renamed without changes.
4 changes: 4 additions & 0 deletions examples/react/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import eslint from '@ice/spec/eslint';

// script: eslint --ext .js,.jsx,.tsx,.ts ./ --resolve-plugins-relative-to ./packages/spec
export default eslint.getConfig();
12 changes: 12 additions & 0 deletions examples/react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@ice/spec-example-react",
"version": "0.0.1",
"private": true,
"scripts": {
"lint:code": "eslint .",
"lint:style": "stylelint src/**/*.{css,scss,less}"
},
"devDependencies": {
"@ice/spec": "workspace:*"
}
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions examples/react/stylelint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@ice/spec/stylelint';
6 changes: 0 additions & 6 deletions lerna.json

This file was deleted.

44 changes: 23 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
{
"name": "iceworks-spec",
"name": "ice-spec-monorepo",
"private": true,
"devEngines": {
"node": "8.x || 9.x || 10.x || 11.x",
"npm": "6.x"
},
"type": "module",
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"codecov": "^3.6.1",
"commitlint-config-ali": "^0.1.0",
"eslint": "^7.22.0",
"husky": "^7.0.1",
"@ice/pkg": "^1.6.0",
"@ice/spec": "workspace:*",
"eslint": "^9.0.0",
"husky": "^9.1.6",
"ice-npm-utils": "^2.0.1",
"jest": "^24.9.0",
"lerna": "^3.18.2",
"prettier": "^2.1.0",
"stylelint": "^13.2.0",
"typescript": "^3.5.3"
"lint-staged": "^15.2.10",
"prettier": "^3.0.0",
"stylelint": "^16.0.0",
"typescript": "^5.6.0",
"vitest": "^2.1.4"
},
"scripts": {
"prepare": "husky install",
"setup": "rm -rf ./packages/*/node_modules && lerna bootstrap --no-ci && lerna link",
"lint": "eslint --ext .js,.jsx,.tsx,.ts ./ --resolve-plugins-relative-to ./packages/spec",
"lint": "eslint ./",
"prettier": "prettier **/* --write",
"test": "jest && cd packages/spec && npm run test",
"test": "vitest run",
"publish": "node ./scripts/publish",
"ci": "npm run setup && npm run lint && npm run test"
},
"jest": {
"coverageDirectory": "./coverage/",
"collectCoverage": true
"packageManager": "[email protected]",
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md,css,scss,less}": [
"prettier --write"
]
}
}
}
6 changes: 2 additions & 4 deletions packages/eslint-plugin-best-practices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"access": "public"
},
"dependencies": {
"@iceworks/spec": "^1.0.0",
"@ice/spec": "workspace:^",
"@mdn/browser-compat-data": "^4.0.5",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
Expand All @@ -27,7 +27,5 @@
"require-all": "^3.0.0",
"semver": "^7.3.2"
},
"devDependencies": {
"eslint": "^7.22.0"
}
"devDependencies": {}
}
16 changes: 0 additions & 16 deletions packages/spec/.editorconfig

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.eslintrc.common-ts.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.eslintrc.common.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.eslintrc.rax-ts.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.eslintrc.rax.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.eslintrc.react-ts.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.eslintrc.react.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.eslintrc.vue-ts.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.eslintrc.vue.js

This file was deleted.

7 changes: 0 additions & 7 deletions packages/spec/.stylelintignore

This file was deleted.

3 changes: 0 additions & 3 deletions packages/spec/.stylelintrc.js

This file was deleted.

7 changes: 7 additions & 0 deletions packages/spec/build.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {defineConfig} from '@ice/pkg';

export default defineConfig({
transform: {
formats: ['es2017']
}
})
5 changes: 0 additions & 5 deletions packages/spec/examples/common/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions packages/spec/examples/rax-ts/index.css

This file was deleted.

16 changes: 0 additions & 16 deletions packages/spec/examples/rax-ts/index.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions packages/spec/examples/rax/index.css

This file was deleted.

Loading

0 comments on commit 2572597

Please sign in to comment.