typescript-eslint
TS项目中使用eslint规范ts代码的配置示例
{
"extends": "", // 指定配置的字符串(配置文件的路径、可共享配置的名称、eslint:recommended 或 eslint:all)
"globals": { // 脚本在执行期间访问的额外的全局变量
"my": true,
"App": true,
"Component": true,
"Page": true
},
"parser": "@typescript-eslint/parser", //针对ts文件进行解析的解析器
"plugins": ["typescript"],
"rules": {
"typescript/class-name-casing": "error",
"typescript/type-annotation-spacing": "error"
}
}
module.exports = {
extends: [
'plugin:react/recommended'
'plugin:@typescript-eslint/recommended'
], //使用推荐的React代码检测规范
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
env:{
browser: true,
node: true,
},
settings: { //自动发现React的版本,从而进行规范react代码
"react": {
"pragma": "React",
"version": "detect"
}
},
parserOptions: { //指定ESLint可以解析JSX语法
"ecmaVersion": 2019,
"sourceType": 'module',
"ecmaFeatures":{
jsx:true
}
}
rules: {
}
}
.gitlab-ci.yml官方配置说明
image: ruby:2.1
services:
- postgres
before_script: // 重写一组在作业前执行的命令
- bundle install
after_script: // 重写一组在作业后执行的命令
- rm secrets
stages: // 定义构建阶段
- build
- test
- deploy
job1: // 带有约束说明的任务
stage: build
script:
- execute-script-for-job1
only:
- master
tags:
- docker
.aci.yml
# 不要修改该文件,会自动生成
stages:
- test
environments:
NODE_ENV: "test"
beforeScript:
- |
export PATH=$PWD/node_modules/.bin:$HOME/.npm_global/tnpm/bin:$PATH
echo $PATH
time curl -v -L -o- https://bash-scripts.antfin-inc.com/install-tnpm-standalone.js | bash
tnpm -v
node-12:
stage: test
aciTags: DOCKER
agent:
docker:
image: reg.docker.alibaba-inc.com/dockerlab/node-ci:3.7.11
resourceRequirements:
cpu: 4
memory: 12
ephemeral-storage: 30
script:
- |
export PATH=$PWD/node_modules/.bin:$HOME/.npm_global/tnpm/bin:$PATH
time tnpm i --install-node=12 --no-cache
node -e "console.log('%j, %j', process.versions, process.execPath)"
time tnpm run ci
Eslint插件推荐
阿里前端规约Eslint共享配置:https://www.npmjs.com/package/eslint-config-ali