Browse Source

refactor(template): eslint prettier sass uview tailwindcss

develop
wally 4 years ago
parent
commit
9c966a13bd
  1. 8
      .editorconfig
  2. 1
      .eslintcache
  3. 11
      .eslintignore
  4. 40
      .eslintrc.js
  5. 9
      .prettierignore
  6. 13
      .prettierrc
  7. 6
      CHANGELOG.md
  8. 62
      babel.config.js
  9. 1
      commitlint.config.js
  10. 47
      package.json
  11. 26
      postcss.config.js
  12. BIN
      public/img/icons/android-chrome-192x192.png
  13. BIN
      public/img/icons/android-chrome-512x512.png
  14. BIN
      public/img/icons/android-chrome-maskable-192x192.png
  15. BIN
      public/img/icons/android-chrome-maskable-512x512.png
  16. BIN
      public/img/icons/apple-touch-icon-120x120.png
  17. BIN
      public/img/icons/apple-touch-icon-152x152.png
  18. BIN
      public/img/icons/apple-touch-icon-180x180.png
  19. BIN
      public/img/icons/apple-touch-icon-60x60.png
  20. BIN
      public/img/icons/apple-touch-icon-76x76.png
  21. BIN
      public/img/icons/apple-touch-icon.png
  22. BIN
      public/img/icons/favicon-16x16.png
  23. BIN
      public/img/icons/favicon-32x32.png
  24. BIN
      public/img/icons/msapplication-icon-144x144.png
  25. BIN
      public/img/icons/mstile-150x150.png
  26. 3
      public/img/icons/safari-pinned-tab.svg
  27. 2
      public/robots.txt
  28. 20
      src/App.vue
  29. 5
      src/common/styles/index.css
  30. 16
      src/main.js
  31. 49
      src/pages/index/index.vue
  32. 29
      src/registerServiceWorker.js
  33. 7
      tailwind.config.js
  34. 13
      vue.config.js
  35. 3084
      yarn.lock

8
.editorconfig

@ -0,0 +1,8 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 140
root = true

1
.eslintcache

@ -0,0 +1 @@
[{"/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/commitlint.config.js":"1","/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/src/main.js":"2","/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/src/registerServiceWorker.js":"3","/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/tailwind.config.js":"4","/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/vue.config.js":"5"},{"size":85,"mtime":1623918227177,"results":"6","hashOfConfig":"7"},{"size":222,"mtime":1623973598320,"results":"8","hashOfConfig":"7"},{"size":882,"mtime":1623918165160,"results":"9","hashOfConfig":"7"},{"size":160,"mtime":1623973181665},{"size":398,"mtime":1623918227183,"results":"10","hashOfConfig":"7"},{"filePath":"11","messages":"12","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"ssjk3q",{"filePath":"13","messages":"14","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"15","messages":"16","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"17","messages":"18","errorCount":2,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/commitlint.config.js",[],"/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/src/main.js",[],"/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/src/registerServiceWorker.js",[],"/mnt/c/Users/Administrator/Documents/coding/ccsens/tall-mui-cli/vue.config.js",["19","20"],{"ruleId":"21","severity":2,"message":"22","line":1,"column":7,"nodeType":"23","endLine":1,"endColumn":11},{"ruleId":"21","severity":2,"message":"24","line":2,"column":7,"nodeType":"23","endLine":2,"endColumn":24},"no-unused-vars","'path' is assigned a value but never used.","Identifier","'CopyWebpackPlugin' is assigned a value but never used."]

11
.eslintignore

@ -0,0 +1,11 @@
node_modules
dist/
test
build/
unpackage/
babel.config.js
package.json
postcss.config.js
.eslint.js
vue.config.js
src/common/styles/index.css

40
.eslintrc.js

@ -0,0 +1,40 @@
module.exports = {
root: true,
env: {
node: true,
browser: true,
},
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
rules: {
'vue/html-self-closing': 'off',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-param-reassign': ['error', { props: true, ignorePropertyModificationsFor: ['state'] }],
'max-len': ['error', { code: 140, tabWidth: 2 }],
'object-curly-newline': ['error', { multiline: true }],
'arrow-parens': ['error', 'as-needed'],
'linebreak-style': 'off',
'vue/attributes-order': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/max-attributes-per-line': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/html-indent': 'off',
},
parserOptions: { parser: 'babel-eslint' },
overrides: [
{
files: ['**/__tests__/*.{j,t}s?(x)'],
env: { jest: true },
},
],
globals: {
Vue: true,
VueRouter: true,
Vuex: true,
axios: true,
_: true,
},
};

9
.prettierignore

@ -0,0 +1,9 @@
node_modules
dist/
test
build/
unpackage/
babel.config.js
package.json
postcss.config.js
.eslint.js

13
.prettierrc

@ -0,0 +1,13 @@
{
"printWidth": 140,
"singleQuote": true,
"semi": true,
"trailingComma": "all",
"arrowParens": "avoid",
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"proseWrap": "always",
"endOfLine": "lf"
}

6
CHANGELOG.md

@ -0,0 +1,6 @@
# 0.1.0 (2021-06-18)
范围|描述|commitId
--|--|--
- | init | [c0f1deb](https://gitee.com/mongos/uni-cli-template/commits/c0f1deb)

62
babel.config.js

@ -1,63 +1,57 @@
const plugins = []
const plugins = [];
if (process.env.UNI_OPT_TREESHAKINGNG) {
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'));
}
if (
(
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V8
) ||
(
process.env.UNI_PLATFORM === 'h5' &&
process.env.UNI_H5_BROWSER === 'builtin'
)
(process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8) ||
(process.env.UNI_PLATFORM === 'h5' && process.env.UNI_H5_BROWSER === 'builtin')
) {
const path = require('path')
const path = require('path');
const isWin = /^win/.test(process.platform)
const isWin = /^win/.test(process.platform);
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path);
const input = normalizePath(process.env.UNI_INPUT_DIR)
const input = normalizePath(process.env.UNI_INPUT_DIR);
try {
plugins.push([
require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
{
file (file) {
file = normalizePath(file)
file(file) {
file = normalizePath(file);
if (file.indexOf(input) === 0) {
return path.relative(input, file)
return path.relative(input, file);
}
return false
}
}
])
return false;
},
},
]);
} catch (e) {}
}
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui'];
process.UNI_LIBRARIES.forEach(libraryName => {
plugins.push([
'import',
{
'libraryName': libraryName,
'customName': (name) => {
return `${libraryName}/lib/${name}/${name}`
}
}
])
})
libraryName: libraryName,
customName: name => {
return `${libraryName}/lib/${name}/${name}`;
},
},
]);
});
module.exports = {
presets: [
[
'@vue/app',
{
modules: 'commonjs',
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
}
]
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry',
},
],
plugins
}
],
plugins,
};

1
commitlint.config.js

@ -0,0 +1 @@
module.exports = { extends: ['./node_modules/vue-cli-plugin-commitlint/lib/lint'] };

47
package.json

@ -5,6 +5,7 @@
"scripts": {
"serve": "npm run dev:h5",
"build": "npm run build:h5",
"lint": "vue-cli-service lint",
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
"build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",
@ -19,6 +20,7 @@
"build:quickapp-webview": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build",
"build:quickapp-webview-huawei": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build",
"build:quickapp-webview-union": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build",
"cz": "npm run log && git add . && git cz",
"dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
"dev:custom": "cross-env NODE_ENV=development uniapp-cli custom",
"dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve",
@ -34,6 +36,7 @@
"dev:quickapp-webview-huawei": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch",
"dev:quickapp-webview-union": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build --watch",
"info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",
"log": "conventional-changelog --config ./node_modules/vue-cli-plugin-commitlint/lib/log -i CHANGELOG.md -s -r 0",
"serve:quickapp-native": "node node_modules/@dcloudio/uni-quickapp-native/bin/serve.js",
"test:android": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i",
"test:h5": "cross-env UNI_PLATFORM=h5 jest -i",
@ -57,10 +60,18 @@
"@dcloudio/uni-quickapp-native": "^2.0.0-31920210609001",
"@dcloudio/uni-quickapp-webview": "^2.0.0-31920210609001",
"@dcloudio/uni-stat": "^2.0.0-31920210609001",
"@tailwindcss/postcss7-compat": "^2.2.0",
"@vue/shared": "^3.0.0",
"autoprefixer": "^9",
"core-js": "^3.6.5",
"dayjs": "^1.10.5",
"flyio": "^0.6.2",
"postcss": "^7",
"regenerator-runtime": "^0.12.1",
"register-service-worker": "^1.7.1",
"right-pad": "^1.0.1",
"tailwindcss": "npm:@tailwindcss/postcss7-compat",
"uview-ui": "^1.8.4",
"vue": "^2.6.11",
"vuex": "^3.2.0"
},
@ -77,19 +88,55 @@
"@dcloudio/webpack-uni-mp-loader": "^2.0.0-31920210609001",
"@dcloudio/webpack-uni-pages-loader": "^2.0.0-31920210609001",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-pwa": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.11.0",
"commitizen": "^4.0.3",
"commitlint": "^8.2.0",
"conventional-changelog-cli": "^2.0.28",
"cross-env": "^7.0.2",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^6.2.2",
"husky": "^3.0.9",
"jest": "^25.4.0",
"lint-staged": "^11.0.0",
"mini-types": "*",
"miniprogram-api-typings": "*",
"node-sass": "^6.0.0",
"postcss-comment": "^2.0.0",
"prettier": "^2.2.1",
"sass": "^1.35.1",
"sass-loader": "10",
"vue-cli-plugin-commitlint": "~1.0.12",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"Android >= 4",
"ios >= 8"
],
"config": {
"commitizen": {
"path": "./node_modules/vue-cli-plugin-commitlint/lib/cz"
}
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{js,json,css,vue}": [
"eslint --fix",
"git add"
],
"*.js": "eslint --cache --fix"
},
"uni-app": {
"scripts": {}
}

26
postcss.config.js

@ -1,22 +1,22 @@
const path = require('path')
const path = require('path');
module.exports = {
parser: require('postcss-comment'),
plugins: [
require('postcss-import')({
resolve (id, basedir, importOptions) {
resolve(id, basedir, importOptions) {
if (id.startsWith('~@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3));
} else if (id.startsWith('@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2));
} else if (id.startsWith('/') && !id.startsWith('//')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1));
}
return id
}
}),
require('autoprefixer')({
remove: process.env.UNI_PLATFORM !== 'h5'
return id;
},
}),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
]
}
require('autoprefixer')({ remove: process.env.UNI_PLATFORM !== 'h5' }),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss'),
require('tailwindcss')({}),
],
};

BIN
public/img/icons/android-chrome-192x192.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
public/img/icons/android-chrome-512x512.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
public/img/icons/android-chrome-maskable-192x192.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
public/img/icons/android-chrome-maskable-512x512.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
public/img/icons/apple-touch-icon-120x120.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
public/img/icons/apple-touch-icon-152x152.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
public/img/icons/apple-touch-icon-180x180.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
public/img/icons/apple-touch-icon-60x60.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
public/img/icons/apple-touch-icon-76x76.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
public/img/icons/apple-touch-icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
public/img/icons/favicon-16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

BIN
public/img/icons/favicon-32x32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
public/img/icons/msapplication-icon-144x144.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
public/img/icons/mstile-150x150.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

3
public/img/icons/safari-pinned-tab.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.00251 14.9297L0 1.07422H6.14651L8.00251 4.27503L9.84583 1.07422H16L8.00251 14.9297Z" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 215 B

2
public/robots.txt

@ -0,0 +1,2 @@
User-agent: *
Disallow:

20
src/App.vue

@ -1,17 +1,17 @@
<script>
export default {
onLaunch: function() {
console.log('App Launch')
export default {
onLaunch: function () {
console.log('App Launch');
},
onShow: function() {
console.log('App Show')
onShow: function () {
console.log('App Show');
},
onHide: function() {
console.log('App Hide')
}
}
onHide: function () {
console.log('App Hide');
},
};
</script>
<style>
/*每个页面公共css */
/*每个页面公共css */
</style>

5
src/common/styles/index.css

@ -0,0 +1,5 @@
/* ./src/common/src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

16
src/main.js

@ -1,11 +1,11 @@
import Vue from 'vue'
import App from './App'
import Vue from 'vue';
import App from './App';
import './common/styles/index.css';
import './registerServiceWorker';
Vue.config.productionTip = false
Vue.config.productionTip = false;
App.mpType = 'app'
App.mpType = 'app';
const app = new Vue({
...App
})
app.$mount()
const app = new Vue({ ...App });
app.$mount();

49
src/pages/index/index.vue

@ -1,49 +1,24 @@
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="container p-4">
<image class="avatar" src="/static/logo.png"></image>
<view>
<text class="title">{{title}}</text>
<text class="title">{{ title }}</text>
</view>
</view>
</template>
<script>
export default {
export default {
data() {
return {
title: 'Hello'
}
return { title: 'Hello' };
},
onLoad() {
},
methods: {
}
}
onLoad() {},
methods: {},
};
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin: 200rpx auto 50rpx auto;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
<style lang="scss">
.title {
font-size: 20px;
}
</style>

29
src/registerServiceWorker.js

@ -0,0 +1,29 @@
/* eslint-disable no-console */
import { register } from 'register-service-worker';
if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, {
ready() {
console.log('App is being served from cache by a service worker.\n' + 'For more details, visit https://goo.gl/AFskqB');
},
registered() {
console.log('Service worker has been registered.');
},
cached() {
console.log('Content has been cached for offline use.');
},
updatefound() {
console.log('New content is downloading.');
},
updated() {
console.log('New content is available; please refresh.');
},
offline() {
console.log('No internet connection found. App is running in offline mode.');
},
error(error) {
console.error('Error during service worker registration:', error);
},
});
}

7
tailwind.config.js

@ -0,0 +1,7 @@
module.exports = {
purge: [],
darkMode: false, // or 'media' or 'class'
theme: { extend: {} },
variants: { extend: {} },
plugins: [],
};

13
vue.config.js

@ -0,0 +1,13 @@
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin'); //最新版本copy-webpack-plugin插件暂不兼容,推荐v5.0.0
module.exports = {
lintOnSave: process.env.NODE_ENV !== 'production',
productionSourceMap: false,
devServer: {
open: true,
overlay: { warnings: true, errors: true },
// proxy: {}
},
configureWebpack: { plugins: [] },
};

3084
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save