Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Fix eslint (#32)
Browse files Browse the repository at this point in the history
* chore(packages): update

* fix(eslint): update config

* feat(eslint): wxs config
  • Loading branch information
NewFuture committed Aug 18, 2019
1 parent a783d20 commit 7b7a919
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 53 deletions.
55 changes: 39 additions & 16 deletions .eslintrc.json
Expand Up @@ -2,10 +2,20 @@
"root": true,
"parserOptions": {
"parser": "@typescript-eslint/parser",
"project": "tsconfig.json",
"tsconfigRootDir": "./"
"project": "tsconfig.json"
},
"plugins": ["prettier", "@typescript-eslint"],
"overrides": [
{
"files": ["src/**/*.wxts"],
"parserOptions": {
"parser": "@typescript-eslint/parser",
"createDefaultProgram ": true,
"project": "tsconfig.wxs.json",
"extraFileExtensions": [".wxts"]
}
}
],
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
Expand All @@ -16,8 +26,16 @@
],
"rules": {
"prettier/prettier": "warn",
"no-console": "warn",
"no-cond-assign": ["warn", "always"],
"no-dupe-class-members": "off",
"no-console": "warn",
"require-atomic-updates": "warn",
"sort-vars": [
"warn",
{
"ignoreCase": true
}
],
"require-jsdoc": [
"error",
{
Expand All @@ -27,34 +45,38 @@
}
}
],
"@typescript-eslint/generic-type-naming": 1,
"prefer-const": "error",
"prefer-rest-params": "warn",
"@typescript-eslint/generic-type-naming": "warn",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/member-naming": [
1,
"warn",
{
"private": "^_",
"private": "^_[a-z][a-zA-Z0-9]*$",
"public": "^\\$?[a-z][a-zA-Z0-9]*$"
}
],
"@typescript-eslint/member-ordering": 1,
"@typescript-eslint/no-extraneous-class": [2, {}],
"@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/no-extraneous-class": ["error", {}],
"@typescript-eslint/no-this-alias": [
1,
"warn",
{
"allowedNames": []
}
],
"@typescript-eslint/no-for-in-array": 1,
"@typescript-eslint/no-non-null-assertion": 1,
"@typescript-eslint/no-unnecessary-qualifier": 1,
"@typescript-eslint/no-for-in-array": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-qualifier": "off",
"@typescript-eslint/no-unnecessary-type-assertion": [
2,
"off",
{
"typesToIgnore": []
}
],
"@typescript-eslint/prefer-function-type": 0,
"@typescript-eslint/prefer-function-type": "off",
"@typescript-eslint/explicit-function-return-type": [
1,
"error",
{
"allowExpressions": true
}
Expand All @@ -77,6 +99,7 @@
"clearTimeout": "readonly",
"setInterval": "readonly",
"clearInterval": "readonly",
"requirePlugin": "readonly",
"getRegExp": "readonly",
"getDate": "readonly"
}
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Expand Up @@ -40,3 +40,5 @@ build/Release

# next.js build output
.next

.npmrc
6 changes: 0 additions & 6 deletions .prettierrc
Expand Up @@ -46,12 +46,6 @@
"trailingComma": "all"
}
},
{
"files": ".npmrc",
"options": {
"parser": "markdown"
}
},
{
"files": "*.{wxs,js}",
"options": {
Expand Down
42 changes: 25 additions & 17 deletions .vscode/settings.json
Expand Up @@ -37,6 +37,15 @@
"[wxml]": {
"editor.defaultFormatter": "qiu8310.minapp-vscode",
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"emmet.includeLanguages": {
"wxml": "html",
"wxss": "css",
Expand All @@ -48,25 +57,24 @@
"html.suggest.html5": false,
"htmlhint.documentSelector": ["html", "wxml"],
"dot-template-vscode.watchFilesGlobPattern": "src/**/*",
"emmet.syntaxProfiles": {
"html": {
"filters": "html, bem",
"self_closing_tag": true,
},
},
"minapp-vscode.wxmlFormatter": "prettier",
"minapp-vscode.disableDecorate": true,
"minapp-vscode.linkAttributeNames": ["src"],
"minapp-vscode.globalStyleFiles": ["src/app.scss"],
"minapp-vscode.resolveRoots": ["src"],
"minapp-vscode.selfCloseTags": ["img"],
"minapp-vscode.styleExtensions": ["wxss", "css", "scss"],
"minapp-vscode.documentSelector": ["wxml", "html"],
"minapp-vscode.globalStyleFiles": ["src/app.scss"],
"minapp-vscode.decorateComplexInterpolation": true,
"minapp-vscode.selfCloseTags": [],
"minapp-vscode.snippets": {
"wxml": {
"open-data": {
// prettier-ignore
"body": "<open-data type=\"${1|groupName,userNickName,userAvatarUrl,userGender,userCity,userProvince,userCountry,userLanguage|}\" lang=\"${2|en,zh_CN,zh_TW|}\" ></open-data>$0"
},
},
"wxml": {},
},
// "minapp-vscode.sass": {
// "includePaths": ["${workspaceFolder}/src", "${workspaceFolder}/src/assets"],
// },
// prettier

"prettier.ignorePath": ".prettierignore", // use .prettierignore
"prettier.eslintIntegration": true,
"prettier.stylelintIntegration": true,
Expand All @@ -85,6 +93,10 @@
"fileMatch": ["app.json", "app.jsonc", "app.json5", "app.cjson"],
"url": "https://newfuture.github.io/miniprogram-json-schema/app.json",
},
{
"fileMatch": ["sitemap.json", "sitemap.jsonc", "sitemap.json5", "sitemap.cjson"],
"url": "https://newfuture.github.io/miniprogram-json-schema/sitemap.json",
},
{
"fileMatch": [
"project.config.json",
Expand All @@ -94,10 +106,6 @@
],
"url": "https://newfuture.github.io/miniprogram-json-schema/project.config.json",
},
{
"fileMatch": ["sitemap.json", "sitemap.jsonc", "sitemap.json5", "sitemap.cjson"],
"url": "https://newfuture.github.io/miniprogram-json-schema/sitemap.json",
},
{
"fileMatch": [
"src/pages/**/*.jsonc",
Expand Down
14 changes: 14 additions & 0 deletions .vscode/wxml.code-snippets
@@ -0,0 +1,14 @@
{
"prettier-ignore": {
"scope": "wxml,html",
"prefix": ["<!--"],
"body": "$BLOCK_COMMENT_START ${1|prettier-ignore-attribute class,prettier-ignore|} $BLOCK_COMMENT_END$0",
"description": "prettier ignore attribute",
},
"prettier-ignore-attribute": {
"scope": "html",
"prefix": ["prettier-ignore-attribute"],
"body": "$BLOCK_COMMENT_START prettier-ignore-attribute ${1|style,class|} $BLOCK_COMMENT_END$0",
"description": "prettier ignore attribute",
},
}
26 changes: 13 additions & 13 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "miniprogram-template",
"version": "0.1.1",
"version": "0.1.3",
"description": "Mini Program Template Projects",
"repository": {
"type": "git",
Expand All @@ -21,10 +21,10 @@
"fix": "npm run prettier-fix && npm run lint-fix",
"help": "miniprogram-build -h",
"lint": "npm run lint:js && npm run lint:wxss && npm run lint:wxml && npm run lint:config",
"lint-fix": "npm run lint-fix:wxss && npm run lint-fix:js && npm run lint-fix:config",
"lint-fix:config": "prettier *.json .*rc \"env/*\" \".vscode/*\" --write",
"lint-fix:js": "eslint \"src/**/*.{ts,js,wxs,wxts}\" --fix",
"lint-fix:wxss": "stylelint \"src/**/*\" --fix",
"lint-fix": "npm run fix:wxss && npm run fix:js && npm run fix:config",
"fix:config": "prettier *.json .*rc \"env/*\" \".vscode/*\" --write",
"fix:js": "eslint \"src/**/*.{ts,js,wxs,wxts}\" --fix",
"fix:wxss": "stylelint \"src/**/*\" --fix",
"lint:config": "prettier *.json .*rc \"env/*\" \".vscode/*\" --check",
"lint:js": "eslint \"src/**/*.{ts,js,wxs,wxts}\"",
"lint:wxml": "htmlhint \"src/**/*.{wxml,html}\"",
Expand All @@ -47,12 +47,12 @@
"tslib": "^1.10.0"
},
"devDependencies": {
"@dragongate/miniprogram-api-typings": "^2.7.7",
"@dragongate/miniprogram-api-typings": "^2.7.14",
"@types/miniprogram-wxs": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"eslint": "^6.0.1",
"eslint-config-prettier": "^5.1.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"htmlhint": "^0.11.0",
"miniprogram-build": "^6.4.3",
Expand All @@ -61,9 +61,9 @@
"stylelint-config-prettier": "^5.2.0",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-config-recommended-scss": "^3.3.0",
"stylelint-order": "^3.0.0",
"stylelint-order": "^3.0.1",
"stylelint-prettier": "^1.1.1",
"stylelint-scss": "^3.8.0",
"typescript": "^3.5.2"
"stylelint-scss": "^3.9.3",
"typescript": "^3.5.3"
}
}
1 change: 0 additions & 1 deletion src/app.ts
Expand Up @@ -41,7 +41,6 @@ App({
// 获取用户信息
wx.getSetting({
success: (res) => {
//@ts-ignore
if (res.authSetting["scope.userInfo"]) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
}
Expand Down
8 changes: 8 additions & 0 deletions tsconfig.wxs.json
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*.wxts"],
"compilerOptions": {
"types": [],
"lib": []
}
}

0 comments on commit 7b7a919

Please sign in to comment.