Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@applint/spec
Advanced tools
在 ICE、Rax、React 项目中更简单接入 ESLint(support TypeScript) / Stylelint / Prettier / Commitlint 规则。
在 ICE、Rax、React 项目中更简单接入 ESLint(支持 TypeScript) / Stylelint / Prettier / Commitlint 规则,规则与阿里巴巴大淘宝前端规范保持一致。
npm i --save-dev @applint/spec eslint stylelint prettier @commitlint/cli husky
注意: 你不需要安装任何其他 Lint 插件或者插件集,@applint/spec 中已包含这部分依赖。
运行以下命令可一键迁移到 @applint/spec
中:
tnpx @applint/projectlint codemod --transform 'lint-config-to-applint-spec' --fix
在项目根目录下创建 .eslintrc.js
文件,并加入以下配置:
// .eslintrc.js
const { getESLintConfig } = require('@applint/spec');
// getESLintConfig(rule: 'common' | 'common-ts' | 'rax' | 'rax-ts' | 'react' | 'react-ts' | 'vue' | 'vue-ts', customConfig?: Linter.Config);
module.exports = getESLintConfig('react', {
// 自定义配置
// rules: { 'no-console': 0 }
});
ESLint 规则基于 @applint/eslint-config。
然后在 package.json
中加入脚本:
{
"scripts": {
+ "eslint": "eslint --ext .js,.jsx,.ts,.tsx ./",
+ "eslint:fix": "npm run eslint -- --fix"
}
}
在终端运行 npm run eslint
查看项目有哪些 Lint 问题;运行 npm run eslint:fix
会让 ESLint 尝试修复能被自动修复的问题。
如果你希望对项目中的 TypeScript 代码进行更严格的约束,可以使用 'rax-ts-strict' | 'react-ts-strict' | 'common-ts-strict' (依据你的具体场景)。
// .eslintrc.js
const { getESLintConfig } = require('@applint/spec');
// getESLintConfig(rule: 'common-ts-strict' | 'rax-ts-strict' | 'react-ts-strict', customConfig?: Linter.Config);
module.exports = getESLintConfig('react-ts-strict', {
// 自定义配置
// rules: { 'no-console': 0 }
});
注意:
?.
替代逻辑与&&
,使用空值合并??
替代逻辑或||
等),TS 专有能力(使用 import type 导入类型等)。在项目根目录下创建 .stylelintrc.js
,并加入以下配置:
// .stylelintrc.js
const { getStylelintConfig } = require('@applint/spec');
// getStylelintConfig(rule: 'common' | 'rax' | 'react' | 'vue', customConfig?: StylelintConfig);
module.exports = getStylelintConfig('react');
Stylelint 规则基于 @applint/stylelint-config。
然后在 package.json
中加入脚本:
{
"scripts": {
+ "stylelint": "stylelint \"**/*.{css,scss,less}\"",
+ "stylelint:fix": "npm run stylelint -- --fix"
}
}
在终端运行 npm run stylelint
查看项目有哪些 Lint 问题;运行 npm run stylelint:fix
会让 Stylelint 尝试修复能被自动修复的问题。
在项目根目录下创建 .prettierrc.js
,并加入以下配置:
// .prettierrc.js
const { getPrettierConfig } = require('@applint/spec');
// getPrettierConfig(rule: 'common' | 'rax' | 'react' | 'vue', customConfig?: PrettierConfig);
module.exports = getPrettierConfig('react');
规则基于 @applint/prettier-config。
然后在 package.json
中加入脚本:
{
"scripts": {
+ "prettier": "prettier **/* --write"
}
}
运行 npm run prettier
会使用 Prettier 对代码进行格式化。
ESLint 的某些规则可能会跟 Prettier 格式化的结果有冲突,比如 @typescript-eslint/indent 规则。需要做以下的安装和配置来解决此问题:
npm install --save-dev eslint-config-prettier eslint-plugin-prettier
// .eslintrc.js
const { getESLintConfig } = require('@applint/spec');
module.exports = getESLintConfig('react-ts', {
extends: ['prettier']
});
在项目根目录下创建 .commitlintrc.js
,并加入以下配置:
// .commitlintrc.js
const { getCommitlintConfig } = require('@applint/spec');
// getCommitlintConfig(rule: 'common' | 'rax' | 'react' | 'vue', customConfig?: CommitlintUserConfig);
module.exports = getCommitlintConfig('react');
Commitlint 规则基于 @applint/commitlint-config。
推荐查看 husky 文档了解如何创建 "commit-msg
" 和 "pre-commit
" 文档。
FAQs
在 ICE、Rax、React 项目中更简单接入 ESLint(support TypeScript) / Stylelint / Prettier / Commitlint 规则。
The npm package @applint/spec receives a total of 96 weekly downloads. As such, @applint/spec popularity was classified as not popular.
We found that @applint/spec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.