typescript-eslint

TS项目中使用eslint规范ts代码的配置示例

  1. {
  2. "extends": "", // 指定配置的字符串(配置文件的路径、可共享配置的名称、eslint:recommended 或 eslint:all)
  3. "globals": { // 脚本在执行期间访问的额外的全局变量
  4. "my": true,
  5. "App": true,
  6. "Component": true,
  7. "Page": true
  8. },
  9. "parser": "@typescript-eslint/parser", //针对ts文件进行解析的解析器
  10. "plugins": ["typescript"],
  11. "rules": {
  12. "typescript/class-name-casing": "error",
  13. "typescript/type-annotation-spacing": "error"
  14. }
  15. }
  1. module.exports = {
  2. extends: [
  3. 'plugin:react/recommended'
  4. 'plugin:@typescript-eslint/recommended'
  5. ], //使用推荐的React代码检测规范
  6. parser: '@typescript-eslint/parser',
  7. plugins: ['@typescript-eslint'],
  8. env:{
  9. browser: true,
  10. node: true,
  11. },
  12. settings: { //自动发现React的版本,从而进行规范react代码
  13. "react": {
  14. "pragma": "React",
  15. "version": "detect"
  16. }
  17. },
  18. parserOptions: { //指定ESLint可以解析JSX语法
  19. "ecmaVersion": 2019,
  20. "sourceType": 'module',
  21. "ecmaFeatures":{
  22. jsx:true
  23. }
  24. }
  25. rules: {
  26. }
  27. }

.gitlab-ci.yml官方配置说明

  1. image: ruby:2.1
  2. services:
  3. - postgres
  4. before_script: // 重写一组在作业前执行的命令
  5. - bundle install
  6. after_script: // 重写一组在作业后执行的命令
  7. - rm secrets
  8. stages: // 定义构建阶段
  9. - build
  10. - test
  11. - deploy
  12. job1: // 带有约束说明的任务
  13. stage: build
  14. script:
  15. - execute-script-for-job1
  16. only:
  17. - master
  18. tags:
  19. - docker

.aci.yml

  1. # 不要修改该文件,会自动生成
  2. stages:
  3. - test
  4. environments:
  5. NODE_ENV: "test"
  6. beforeScript:
  7. - |
  8. export PATH=$PWD/node_modules/.bin:$HOME/.npm_global/tnpm/bin:$PATH
  9. echo $PATH
  10. time curl -v -L -o- https://bash-scripts.antfin-inc.com/install-tnpm-standalone.js | bash
  11. tnpm -v
  12. node-12:
  13. stage: test
  14. aciTags: DOCKER
  15. agent:
  16. docker:
  17. image: reg.docker.alibaba-inc.com/dockerlab/node-ci:3.7.11
  18. resourceRequirements:
  19. cpu: 4
  20. memory: 12
  21. ephemeral-storage: 30
  22. script:
  23. - |
  24. export PATH=$PWD/node_modules/.bin:$HOME/.npm_global/tnpm/bin:$PATH
  25. time tnpm i --install-node=12 --no-cache
  26. node -e "console.log('%j, %j', process.versions, process.execPath)"
  27. time tnpm run ci

Eslint插件推荐

阿里前端规约Eslint共享配置:https://www.npmjs.com/package/eslint-config-ali