Package Exports
- @iceworks/spec
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@iceworks/spec) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@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
JavaScript + rax, ice and react
rules base on eslint-config-ali and @iceworks/eslint-plugin-best-practices.
// .eslintrc.js
const { getESLintConfig } = require('@iceworks/spec');
// getESLintConfig(rule: 'rax'|'react', customConfig?);
module.exports = getESLintConfig('react');
TypeScript + rax, ice and react
rules base on eslint-config-ali and @iceworks/eslint-plugin-best-practices.
// .eslintrc.js
const { getESLintConfig } = require('@iceworks/spec');
// getESLintConfig(rule: 'rax-ts'|'react-ts', customConfig?);
module.exports = getESLintConfig('react-ts');
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: 'rax'|'react', 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: 'rax'|'react', 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: 'rax'|'react', customConfig?);
module.exports = getCommitlintConfig('react');
FAQ
Custom config
// .eslintrc.js
const { getESLintConfig } = require('@iceworks/spec');
// getESLintConfig(rule: 'rax'|'react', customConfig?);
module.exports = getESLintConfig('rax', {
// custom config it will merge into main config
rules: {
// ...
},
});
Error: Cannot find module 'eslint-plugin-foo'
Eslint is not yet supported having plugins as dependencies in shareable config. issue. 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
{
"include": ["src/*"] // update to "include": ["src/**/*"]
}
Enjoy!