Skip to content

Commit 9dceb9e

Browse files
authored
Merge pull request #49 from michaelfitzhavey/chore/refactor-and-tidy
Housekeeping
2 parents 75765b2 + ebba6bc commit 9dceb9e

20 files changed

+2408
-10341
lines changed

.babelrc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"presets": [
3-
[
4-
"es2015"
5-
]
6-
]
2+
"presets": [
3+
["es2015"]
4+
]
75
}

.eslintrc

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,67 @@
11
{
2-
"env": {
3-
"es6": true,
4-
"mocha": true
5-
},
6-
"extends": "vue",
7-
"parser": "babel-eslint",
8-
"parserOptions": {
9-
"sourceType": "module"
10-
},
11-
"rules": {
12-
"semi": ["error", "always"]
13-
}
2+
"env": {
3+
"es6": true,
4+
"mocha": true
5+
},
6+
"extends": [
7+
"airbnb-base",
8+
"plugin:vue/essential"
9+
],
10+
"parser": "vue-eslint-parser",
11+
"parserOptions": {
12+
"parser": "babel-eslint",
13+
"sourceType": "module"
14+
},
15+
"rules": {
16+
// only apply parens to arrow functions when there are multiple args
17+
"arrow-parens": [2, "as-needed"],
18+
19+
// never have trailing commas
20+
"comma-dangle": [2, "never"],
21+
22+
// allow require in all sorts of places
23+
"global-require": 0,
24+
25+
// always indent with one tab, including switch statements
26+
"indent": [1, "tab", { "SwitchCase": 1 }],
27+
28+
// don"t worry about line endings
29+
"linebreak-style": 0,
30+
31+
// warn for any line over 140 chars
32+
"max-len": [1, 140],
33+
34+
// class constructors must start with a capital letter, allows Router and Object ID without "new"
35+
"new-cap": [2, { "capIsNewExceptions": ["Router", "ObjectId"] }],
36+
37+
// don"t allow modification of any input parameters
38+
"no-param-reassign": [2, { "props": false }],
39+
40+
// allow the ++ operator
41+
"no-plusplus": 0,
42+
43+
// disallow underscore dangle with the exceptions "_id" & "__v"
44+
"no-underscore-dangle": [2, { "allow": ["_id", "__v"] }],
45+
46+
// allow tabs!
47+
"no-tabs": 0,
48+
49+
// allow objects to be defined on a single line
50+
"object-curly-newline": 0,
51+
52+
// use object shorthand wherever possible
53+
"object-shorthand": ["error", "always"],
54+
55+
// allow indentation regardless of blank lines above and below
56+
"padded-blocks": 0,
57+
58+
// ensure properties are either consistently in / without qutoes as needed
59+
"quote-props": [2, "consistent-as-needed"],
60+
61+
// allow us to use webpack while installing it as a devDepencdency
62+
"import/no-extraneous-dependencies": 0,
63+
64+
// arrow functions don't need a consistent return type for all code paths
65+
"consistent-return": 0
66+
}
1467
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Stale Issue / PR Action
2+
# This actions marks issues / PRs stale when they have been inactive for a while.
3+
#
4+
# For configuration options see https://github.com/actions/stale
5+
6+
name: Mark stale issues and pull requests
7+
8+
on:
9+
schedule:
10+
- cron: "0 0 * * *"
11+
12+
jobs:
13+
stale:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/stale@v1
19+
with:
20+
repo-token: ${{ secrets.GITHUB_TOKEN }}
21+
stale-issue-message: 'This issue seems to be stale'
22+
stale-pr-message: 'This PR seems to be stale'
23+
stale-issue-label: 'no-issue-activity'
24+
stale-pr-label: 'no-pr-activity'
25+
days-before-stale: 28 # 4 weeks
26+
days-before-close: 84 # 3 months (ish)

.github/workflows/publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Publish on push to master branch
2+
#
3+
# 1. increment the version in package.json
4+
# 2. push the new version to the master branch
5+
# 3. build the project
6+
# 4. publish the project
7+
8+
# It relies on the `NPM_TOKEN` secret being available in this repo.
9+
10+
name: publish
11+
12+
on:
13+
push:
14+
branches:
15+
- master
16+
17+
jobs:
18+
build-and-publish:
19+
20+
runs-on: ubuntu-latest
21+
22+
strategy:
23+
matrix:
24+
node-version: [10.x]
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
29+
- name: Use Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
34+
- name: Increment project version
35+
run: npm version patch
36+
37+
- name: Build project
38+
run: |
39+
npm ci
40+
npm run build
41+
42+
- name: Commit changes
43+
run: |
44+
git config --local user.email "action@github.com"
45+
git config --local user.name "GitHub Action"
46+
git commit -m "increment package version" -a
47+
48+
- name: Push changes
49+
uses: ad-m/github-push-action@master
50+
with:
51+
github_token: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Publish project
54+
run: |
55+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
56+
npm publish --access public

.stylelintrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
![a demonstration](https://raw.githubusercontent.com/arvidkahl/vue-json-tree-view/master/header.png)
44

5-
_If you'd like to contribute to this project, please raise an issue and we can add you to the contributors_
6-
7-
85
## Demo and Blogpost
96

10-
You can check out the [demo](https://jsfiddle.net/arvidkahl/kwo6vk9d/11/) on JSFiddle and read the Blogpost called [Building a JSON Tree View Component in Vue.js from Scratch in Six Steps](https://devblog.digimondo.io/building-a-json-tree-view-component-in-vue-js-from-scratch-in-six-steps-ce0c05c2fdd8#.dkwh4jo2m) that lead to the creation of this library.
7+
You can check out the [demo](https://jsfiddle.net/arvidkahl/kwo6vk9d/11/) on JSFiddle and read the Blogpost called [Building a JSON Tree View Component in Vue.js from Scratch in Six Steps](http://brianyang.com/building-a-json-tree-view-component-in-vue-js-from-scratch-in-six-steps) that lead to the creation of this library.
118

129
## Installation
1310

@@ -89,11 +86,7 @@ Keys can also be styled. For instance to make labels red:
8986
}
9087
```
9188

92-
## Notes
93-
94-
Enjoy.
95-
96-
## Changelog
89+
## Contributing
90+
Contributions to this repo are very welcome as they are what has helped it become what it is today. Simply raise an issue with new ideas or submit a pull request.
9791

98-
- 2.0.0: Moved prop based option into `options` object. Added CSS for leaf types. Support for raw values as data.
99-
- 1.0.0: Initial Release
92+
A github action automatically deploys changes when they are merged into the master branch.

index.html

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta charset="utf-8">
5-
<title>Vue Component</title>
6-
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
7-
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
8-
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
9-
</head>
10-
<body>
11-
<style type="text/css">
12-
.tree-view-item-value-number {
13-
color: green;
14-
}
15-
.tree-view-item-value-string {
16-
color: blue;
17-
}
18-
.tree-view-item-value-boolean {
19-
color: violet;
20-
}
21-
</style>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Vue Component</title>
6+
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
7+
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
8+
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
9+
</head>
10+
<body>
11+
<style type="text/css">
12+
.tree-view-item-value-number {
13+
color: green;
14+
}
15+
.tree-view-item-value-string {
16+
color: blue;
17+
}
18+
.tree-view-item-value-boolean {
19+
color: violet;
20+
}
21+
</style>
2222

23-
<div id="container" class="container">
23+
<div id="container" class="container">
2424

25-
<div class="row">
26-
<div class="col-sm-6">
27-
<h2>Test String, some Max Depth, Named Root Object</h2>
28-
<pre><code>{{sampleJSONString}}</code></pre>
29-
</div>
30-
<div class="col-sm-6">
31-
<tree-view :data="sampleJSONString" :options="{maxDepth: 2, rootObjectKey: 'The Test String'}"></tree-view>
32-
</div>
33-
</div>
34-
<div class="row">
35-
<div class="col-sm-6">
36-
<h2>Test Array, some Max Depth, Named Root Object, and Auto Linking</h2>
37-
<pre><code>{{sampleJSONArray}}</code></pre>
38-
</div>
39-
<div class="col-sm-6">
40-
<tree-view :data="sampleJSONArray" :options="{maxDepth: 2, rootObjectKey: 'The Test Array', link: true}"></tree-view>
41-
</div>
42-
</div>
25+
<div class="row">
26+
<div class="col-sm-6">
27+
<h2>Test String, some Max Depth, Named Root Object</h2>
28+
<pre><code>{{sampleJSONString}}</code></pre>
29+
</div>
30+
<div class="col-sm-6">
31+
<tree-view :data="sampleJSONString" :options="{maxDepth: 2, rootObjectKey: 'The Test String'}"></tree-view>
32+
</div>
33+
</div>
34+
<div class="row">
35+
<div class="col-sm-6">
36+
<h2>Test Array, some Max Depth, Named Root Object, and Auto Linking</h2>
37+
<pre><code>{{sampleJSONArray}}</code></pre>
38+
</div>
39+
<div class="col-sm-6">
40+
<tree-view :data="sampleJSONArray" :options="{maxDepth: 2, rootObjectKey: 'The Test Array', link: true}"></tree-view>
41+
</div>
42+
</div>
4343

44-
<div class="row">
45-
<div class="col-sm-6">
46-
<h2>No Max Depth, Named Root Object</h2>
47-
<pre><code>{{sampleJSON}}</code></pre>
48-
</div>
49-
<div class="col-sm-6">
50-
<tree-view :data="sampleJSON" :options="{maxDepth: 0, rootObjectKey: 'The named Object'}"></tree-view>
51-
</div>
52-
</div>
44+
<div class="row">
45+
<div class="col-sm-6">
46+
<h2>No Max Depth, Named Root Object</h2>
47+
<pre><code>{{sampleJSON}}</code></pre>
48+
</div>
49+
<div class="col-sm-6">
50+
<tree-view :data="sampleJSON" :options="{maxDepth: 0, rootObjectKey: 'The named Object'}"></tree-view>
51+
</div>
52+
</div>
5353

54-
<div class="row">
55-
<div class="col-sm-6">
56-
<h2>Max Depth set to 2</h2>
57-
<pre><code>{{sampleJSON}}</code></pre>
58-
</div>
59-
<div class="col-sm-6">
60-
<tree-view :data="sampleJSON" :options="{maxDepth: 2}"></tree-view>
61-
</div>
62-
</div>
54+
<div class="row">
55+
<div class="col-sm-6">
56+
<h2>Max Depth set to 2</h2>
57+
<pre><code>{{sampleJSON}}</code></pre>
58+
</div>
59+
<div class="col-sm-6">
60+
<tree-view :data="sampleJSON" :options="{maxDepth: 2}"></tree-view>
61+
</div>
62+
</div>
6363

64-
<div class="row">
65-
<div class="col-sm-6">
66-
<h2>Modifiable</h2>
67-
<pre><code>{{sampleJSON}}</code></pre>
68-
</div>
69-
<div class="col-sm-6">
70-
<tree-view :data="sampleJSON" :options="{modifiable: true}" v-on:change-data="onChangeData" ></tree-view>
71-
</div>
72-
</div>
73-
</div>
74-
<script type="text/javascript" src="/build/build.js"></script>
75-
</body>
76-
</html>
64+
<div class="row">
65+
<div class="col-sm-6">
66+
<h2>Modifiable</h2>
67+
<pre><code>{{sampleJSON}}</code></pre>
68+
</div>
69+
<div class="col-sm-6">
70+
<tree-view :data="sampleJSON" :options="{modifiable: true}" v-on:change-data="onChangeData" ></tree-view>
71+
</div>
72+
</div>
73+
</div>
74+
<script type="text/javascript" src="/build/build.js"></script>
75+
</body>
76+
</html>

0 commit comments

Comments
 (0)