Skip to content

Commit 1095045

Browse files
committed
lint examples
1 parent 751de05 commit 1095045

File tree

14 files changed

+86
-65
lines changed

14 files changed

+86
-65
lines changed

examples/active-links/app.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ const router = new VueRouter({
2323
routes: [
2424
{ path: '/', component: Home },
2525
{ path: '/about', component: About },
26-
{ path: '/users', component: Users, children: [
27-
{ path: ':username', component: User }
28-
]},
26+
{ path: '/users', component: Users,
27+
children: [
28+
{ path: ':username', component: User }
29+
]
30+
}
2931
]
3032
})
3133

32-
const app = new Vue({
34+
new Vue({
3335
router,
3436
template: `
3537
<div id="app">

examples/basic/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const router = new VueRouter({
2525
// 4. Create and mount root instance.
2626
// Make sure to inject the router.
2727
// Route components will be rendered inside <router-view>.
28-
const app = new Vue({
28+
new Vue({
2929
router,
3030
template: `
3131
<div id="app">

examples/data-fetching/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const router = new VueRouter({
1515
]
1616
})
1717

18-
const app = new Vue({
18+
new Vue({
1919
router,
2020
template: `
2121
<div id="app">

examples/named-routes/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const router = new VueRouter({
1717
]
1818
})
1919

20-
const app = new Vue({
20+
new Vue({
2121
router,
2222
template: `
2323
<div id="app">

examples/named-views/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const router = new VueRouter({
3131
]
3232
})
3333

34-
const app = new Vue({
34+
new Vue({
3535
router,
3636
template: `
3737
<div id="app">

examples/navigation-guards/app.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const Bar = { template: '<div>bar</div>' }
1414
* @param {Function} next - confirm the route
1515
*/
1616
function guardRoute (route, redirect, next) {
17-
if (confirm(`Navigate to ${route.path}?`)) {
17+
if (window.confirm(`Navigate to ${route.path}?`)) {
1818
next()
19-
} else if (confirm(`Redirect to home?`)) {
19+
} else if (window.confirm(`Redirect to home?`)) {
2020
redirect('/')
2121
}
2222
}
@@ -33,7 +33,7 @@ const Baz = {
3333
</div>
3434
`,
3535
routeCanDeactivate (route, redirect, next) {
36-
if (this.saved || confirm('Not saved, are you sure you want to navigate away?')) {
36+
if (this.saved || window.confirm('Not saved, are you sure you want to navigate away?')) {
3737
next()
3838
}
3939
}
@@ -67,7 +67,7 @@ router.beforeEach((route, redirect, next) => {
6767
}
6868
})
6969

70-
const app = new Vue({
70+
new Vue({
7171
router,
7272
template: `
7373
<div id="app">

examples/nested-routes/app.js

+20-18
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,29 @@ const router = new VueRouter({
2424
base: __dirname,
2525
routes: [
2626
{ path: '/', redirect: '/parent' },
27-
{ path: '/parent', component: Parent, children: [
28-
// an empty path will be treated as the default, e.g.
29-
// components rendered at /parent: Root -> Parent -> Default
30-
{ path: '', component: Default },
31-
32-
// components rendered at /parent/foo: Root -> Parent -> Foo
33-
{ path: 'foo', component: Foo },
34-
35-
// components rendered at /parent/bar: Root -> Parent -> Bar
36-
{ path: 'bar', component: Bar },
37-
38-
// NOTE absolute path here!
39-
// this allows you to leverage the component nesting without being
40-
// limited to the nested URL.
41-
// components rendered at /baz: Root -> Parent -> Baz
42-
{ path: '/baz', component: Baz }
43-
]}
27+
{ path: '/parent', component: Parent,
28+
children: [
29+
// an empty path will be treated as the default, e.g.
30+
// components rendered at /parent: Root -> Parent -> Default
31+
{ path: '', component: Default },
32+
33+
// components rendered at /parent/foo: Root -> Parent -> Foo
34+
{ path: 'foo', component: Foo },
35+
36+
// components rendered at /parent/bar: Root -> Parent -> Bar
37+
{ path: 'bar', component: Bar },
38+
39+
// NOTE absolute path here!
40+
// this allows you to leverage the component nesting without being
41+
// limited to the nested URL.
42+
// components rendered at /baz: Root -> Parent -> Baz
43+
{ path: '/baz', component: Baz }
44+
]
45+
}
4446
]
4547
})
4648

47-
const app = new Vue({
49+
new Vue({
4850
router,
4951
template: `
5052
<div id="app">

examples/redirect/app.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ const router = new VueRouter({
1414
mode: 'history',
1515
base: __dirname,
1616
routes: [
17-
{ path: '/', component: Home, children: [
18-
{ path: '', component: Default },
19-
{ path: 'foo', component: Foo },
20-
{ path: 'bar', component: Bar },
21-
{ path: 'baz', name: 'baz', component: Baz },
22-
// relative redirect to a sibling route
23-
{ path: 'relative-redirect', redirect: 'foo' },
24-
]},
17+
{ path: '/', component: Home,
18+
children: [
19+
{ path: '', component: Default },
20+
{ path: 'foo', component: Foo },
21+
{ path: 'bar', component: Bar },
22+
{ path: 'baz', name: 'baz', component: Baz },
23+
// relative redirect to a sibling route
24+
{ path: 'relative-redirect', redirect: 'foo' }
25+
]
26+
},
2527
// absolute redirect
2628
{ path: '/absolute-redirect', redirect: '/bar' },
2729
// named redirect
@@ -32,11 +34,11 @@ const router = new VueRouter({
3234
{ path: '/redirect-with-params/:id', redirect: '/with-params/:id' },
3335

3436
// catch all redirect
35-
{ path: '*', redirect: '/' },
37+
{ path: '*', redirect: '/' }
3638
]
3739
})
3840

39-
const app = new Vue({
41+
new Vue({
4042
router,
4143
template: `
4244
<div id="app">

examples/route-alias/app.js

+26-13
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,40 @@ const router = new VueRouter({
1212
mode: 'history',
1313
base: __dirname,
1414
routes: [
15-
{ path: '/home', component: Home, children: [
16-
// absolute alias
17-
{ path: 'foo', component: Foo, alias: '/foo' },
18-
// relative alias (alias to /home/bar-alias)
19-
{ path: 'bar', component: Bar, alias: 'bar-alias' },
20-
// multiple aliases
21-
{ path: 'baz', component: Baz, alias: ['/baz', 'baz-alias'] }
22-
]}
15+
{ path: '/home', component: Home,
16+
children: [
17+
// absolute alias
18+
{ path: 'foo', component: Foo, alias: '/foo' },
19+
// relative alias (alias to /home/bar-alias)
20+
{ path: 'bar', component: Bar, alias: 'bar-alias' },
21+
// multiple aliases
22+
{ path: 'baz', component: Baz, alias: ['/baz', 'baz-alias'] }
23+
]
24+
}
2325
]
2426
})
2527

26-
const app = new Vue({
28+
new Vue({
2729
router,
2830
template: `
2931
<div id="app">
3032
<h1>Route Alias</h1>
3133
<ul>
32-
<li><router-link to="/foo">/foo (renders /home/foo)</router-link></li>
33-
<li><router-link to="/home/bar-alias">/home/bar-alias (renders /home/bar)</router-link></li>
34-
<li><router-link to="/baz">/baz (renders /home/baz)</router-link></li>
35-
<li><router-link to="/home/baz-alias">/home/baz-alias (renders /home/baz)</router-link></li>
34+
<li><router-link to="/foo">
35+
/foo (renders /home/foo)
36+
</router-link></li>
37+
38+
<li><router-link to="/home/bar-alias">
39+
/home/bar-alias (renders /home/bar)
40+
</router-link></li>
41+
42+
<li><router-link to="/baz">
43+
/baz (renders /home/baz)</router-link>
44+
</li>
45+
46+
<li><router-link to="/home/baz-alias">
47+
/home/baz-alias (renders /home/baz)
48+
</router-link></li>
3649
</ul>
3750
<router-view class="view"></router-view>
3851
</div>

examples/route-matching/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const router = new VueRouter({
1414
// params are denoted with a colon ":"
1515
{ path: '/params/:foo/:bar' },
1616
// a param can be made optional by adding "?"
17-
{ path: '/optional-params/:foo?'},
17+
{ path: '/optional-params/:foo?' },
1818
// a param can be followed by a regex pattern in parens
1919
// this route will only be matched if :id is all numbers
2020
{ path: '/params-with-regex/:id(\\d+)' },
@@ -25,7 +25,7 @@ const router = new VueRouter({
2525
]
2626
})
2727

28-
const app = new Vue({
28+
new Vue({
2929
router,
3030
template: `
3131
<div id="app">

examples/scroll-behavior/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ const router = new VueRouter({
2727
base: __dirname,
2828
scrollBehavior,
2929
routes: [
30-
{ path: '/', component: Home, meta: { scrollToTop: true } },
30+
{ path: '/', component: Home, meta: { scrollToTop: true }},
3131
{ path: '/foo', component: Foo },
3232
{ path: '/bar', component: Bar }
3333
]
3434
})
3535

36-
const app = new Vue({
36+
new Vue({
3737
router,
3838
template: `
3939
<div id="app">

examples/transitions/app.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ const router = new VueRouter({
4545
base: __dirname,
4646
routes: [
4747
{ path: '/', component: Home },
48-
{ path: '/parent', component: Parent, children: [
49-
{ path: '', component: Default },
50-
{ path: 'foo', component: Foo },
51-
{ path: 'bar', component: Bar }
52-
]}
48+
{ path: '/parent', component: Parent,
49+
children: [
50+
{ path: '', component: Default },
51+
{ path: 'foo', component: Foo },
52+
{ path: 'bar', component: Bar }
53+
]
54+
}
5355
]
5456
})
5557

56-
const app = new Vue({
58+
new Vue({
5759
router,
5860
template: `
5961
<div id="app">

examples/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
}, {}),
1818

1919
output: {
20-
path: __dirname + '/__build__',
20+
path: path.join(__dirname, '__build__'),
2121
filename: '[name].js',
2222
chunkFilename: '[id].chunk.js',
2323
publicPath: '/__build__/'

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"dev": "node examples/server.js",
2020
"dev-dist": "rollup -wcm",
2121
"build": "rollup -c && uglifyjs dist/vue-router.js -c -m -o dist/vue-router.min.js",
22-
"lint": "eslint src",
22+
"lint": "eslint src examples",
2323
"test": "npm run lint && flow check"
2424
},
2525
"devDependencies": {

0 commit comments

Comments
 (0)