Giter Site home page Giter Site logo

ice-lab / spec Goto Github PK

View Code? Open in Web Editor NEW
62.0 13.0 7.0 169 KB

:hatching_chick: easy to use eslint/stylelint/tslint/prettier/...

JavaScript 85.03% CSS 0.25% TypeScript 9.47% SCSS 3.43% Vue 1.53% Shell 0.28%
eslint stylelint linter prettier tslint

spec's Introduction

@iceworks/spec

Easy to use eslint(support TypeScript) / stylelint / prettier / commitlint in rax, ice and react project. And spec means specification.

Install

$ 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

rules base on eslint-config-ali and @iceworks/eslint-plugin-best-practices.

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

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

stylelint

1. Create configuration file

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

2. Update config

rules base on stylelint-config-ali

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

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

prettier rules

1. Create configuration file

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

2. Update config

// .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 base on commitlint-config-ali

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

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

FAQ

Custom config

// .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:

"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, then create "commit-msg" and "pre-commit" config.

Update from @ice/spec

If you are using @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 ๐Ÿ˜.

Develop

Run Test

npm run test

run test for specific component

npm run test -- packages/spec

Run Prettier

npm run prettier

Run Lint

npm run lint

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.