跳到主要内容

参考配置

项目配置​

{
"miniprogramRoot": "src/",
"compileType": "miniprogram",
"setting": {
"es6": true,
"enhance": true,
"postcss": true,
"minified": true,
"minifyWXSS": true,
"minifyWXML": true,
"uglifyFileName": true,
"ignoreUploadUnusedFiles": true,
"autoAudits": true,
"urlCheck": true,
"compileHotReLoad": true,
"preloadBackgroundData": false,
"lazyloadPlaceholderEnable": false,
"useStaticServer": false,
"bigPackageSizeSupport": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useCompilerPlugins": [
"typescript",
"sass"
],
"disableUseStrict": false,
"uploadWithSourceMap": true,
"packNpmManually": true,
"packNpmRelationList": [
{
"packageJsonPath": "./package.json",
"miniprogramNpmDistDir": "./src"
}
],
"coverView": true,
"ignoreDevUnusedFiles": true,
"checkInvalidKey": true,
"showShadowRootInWxmlPanel": true,
"useIsolateContext": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"useLanDebug": false,
"enableEngineNative": false,
"showES6CompileOption": false,
"newFeature": false,
"nodeModules": true,
"scopeDataCheck": false,
"checkSiteMap": true,
"userConfirmedBundleSwitch": false
},
"libVersion": "3.16.2",
"appid": "wx768c7751fe2b26c3",
"projectname": "老魏小程序实践",
"packOptions": {
"ignore": [],
"include": []
}
}

ESLint 配置​

npm i eslint eslint-config-airbnb-base eslint-config-airbnb-typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import --save-dev
// .eslintrc.js

const globals = {
require: true,
Page: true,
wx: true,
App: true,
getApp: true,
getCurrentPages: true,
Component: true,
getRegExp: true,
Behavior: true,
};

module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'airbnb-base',
'airbnb-typescript/base',
'plugin:@typescript-eslint/recommended',
],
globals,
};

Jest 配置​

npm i @babel/core @babel/preset-env babel-jest@27 jest@27 miniprogram-simulate --save-dev
// jest.config.js

module.exports = {
testEnvironment: 'jsdom',
snapshotSerializers: ['miniprogram-simulate/jest-snapshot-plugin'],
};
// babel.config.js

// 这里的 Babel 仅仅是为了 Jest 的运行,不会在小程序的构建中使用
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: true,
},
},
],
],
};