Skip to content

Commit

Permalink
style: fix standard issues
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig authored and Guria committed Jun 28, 2021
1 parent 5ec4583 commit 4409178
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module.exports = {
env: {
browser: true,
commonjs: true,
commonjs: true
},
extends: ['eslint:recommended', 'standard', 'plugin:prettier/recommended', 'prettier'],
parserOptions: {
ecmaVersion: 2015,
ecmaVersion: 2015
},
rules: {
'no-var': 'off',
'prettier/prettier': 'error',
},
'prettier/prettier': 'error'
}
}
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"trailingComma": "es5",
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
Expand Down
2 changes: 1 addition & 1 deletion compileRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function compileRoute(route, options) {
}

return path + (queryString ? querySeparator + queryString : '')
},
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var object = {
baz: ['foo', 'bar', 'baz', true, false, undefined, null],
qux: '',
quux: null,
garply: undefined,
},
garply: undefined
}
}

var url = urlMapper.stringify('/:foo', object)
Expand All @@ -21,6 +21,6 @@ console.log(parsed)

var mapped = urlMapper.map(url, {
'/:foo': 'one',
'/:foo/bar': 'two',
'/:foo/bar': 'two'
})
console.log(mapped)
4 changes: 2 additions & 2 deletions mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = function mapper(compileFn, options) {
return {
route: route,
match: match,
values: values,
values: values
}
}
}
Expand All @@ -44,6 +44,6 @@ module.exports = function mapper(compileFn, options) {
return {
parse: parse,
stringify: stringify,
map: map,
map: map
}
}
52 changes: 26 additions & 26 deletions tests/urlMapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('mapper', function () {
})
return {
parse: parse,
stringify: stringify,
stringify: stringify
}
})

Expand Down Expand Up @@ -95,7 +95,7 @@ describe('mapper', function () {
it('should pass route and options arguments to compileFn', function () {
var options = {}
var routes = {
':url': {},
':url': {}
}
var mapper = Mapper(compileFn, options)

Expand All @@ -106,7 +106,7 @@ describe('mapper', function () {
it('should return matched route and parsed values', function () {
var routes = {
':url1': 'match1',
':url2': 'match2',
':url2': 'match2'
}
var mapper = Mapper(compileFn)

Expand All @@ -115,24 +115,24 @@ describe('mapper', function () {
match: 'match1',
values: {
route: ':url1',
url: 'url1',
},
url: 'url1'
}
})

expect(mapper.map('url2', routes)).toEqual({
route: ':url2',
match: 'match2',
values: {
route: ':url2',
url: 'url2',
},
url: 'url2'
}
})
})

it('should return only first matched route and parsed values', function () {
var routes = {
':url': 'match1',
':url1': 'match2',
':url1': 'match2'
}
var mapper = Mapper(compileFn)

Expand All @@ -141,8 +141,8 @@ describe('mapper', function () {
match: 'match1',
values: {
route: ':url',
url: 'url11',
},
url: 'url11'
}
})
})

Expand All @@ -167,7 +167,7 @@ describe('urlMapper', function () {

expect(mapper.parse('/:foo/:bar', '/bar/baz')).toEqual({
foo: 'bar',
bar: 'baz',
bar: 'baz'
})
})

Expand All @@ -176,7 +176,7 @@ describe('urlMapper', function () {

expect(mapper.parse('/:foo/:bar', '/bar/baz?query')).toEqual({
foo: 'bar',
bar: 'baz',
bar: 'baz'
})
})

Expand All @@ -185,7 +185,7 @@ describe('urlMapper', function () {

expect(mapper.parse('/:foo/:bar', '/bar/baz#hash')).toEqual({
foo: 'bar',
bar: 'baz',
bar: 'baz'
})
})

Expand All @@ -203,7 +203,7 @@ describe('urlMapper', function () {
foo: 'bar',
bar: 'baz',
baz: 'foo',
qux: {},
qux: {}
})
).toEqual('/bar/baz')
})
Expand All @@ -214,7 +214,7 @@ describe('urlMapper', function () {
foo: true,
bar: false,
baz: 42,
qux: null,
qux: null
}
// URLON-like notation
var url = '/:true/:false/:42/:null'
Expand All @@ -226,7 +226,7 @@ describe('urlMapper', function () {
it('should properly escape unsafe symbols in segments', function () {
var mapper = urlMapper()
var object = {
foo: 'foo/?#\'"bar',
foo: 'foo/?#\'"bar'
}

var url = '/foo%2F%3F%23%27%22bar'
Expand All @@ -242,7 +242,7 @@ describe('urlMapper', function () {
mapper.stringify('/:foo', {
foo: {},
bar: 'baz',
baz: 'foo',
baz: 'foo'
})
}).toThrow()
})
Expand All @@ -254,7 +254,7 @@ describe('urlMapper', function () {

expect(mapper.parse('/:foo/:bar', '/bar/baz')).toEqual({
foo: 'bar',
bar: 'baz',
bar: 'baz'
})
})

Expand All @@ -264,7 +264,7 @@ describe('urlMapper', function () {
expect(mapper.parse('/:foo/:bar', '/bar/baz?baz=foo')).toEqual({
foo: 'bar',
bar: 'baz',
baz: 'foo',
baz: 'foo'
})
})

Expand All @@ -273,13 +273,13 @@ describe('urlMapper', function () {

expect(mapper.parse('/:foo/:bar', '/bar/baz#hash')).toEqual({
foo: 'bar',
bar: 'baz',
bar: 'baz'
})

expect(mapper.parse('/:foo/:bar', '/bar/baz?baz=foo#hash')).toEqual({
foo: 'bar',
bar: 'baz',
baz: 'foo',
baz: 'foo'
})
})

Expand All @@ -295,7 +295,7 @@ describe('urlMapper', function () {
expect(
mapper.stringify('/:foo/:bar', {
foo: 'bar',
bar: 'baz',
bar: 'baz'
})
).toEqual('/bar/baz')
})
Expand All @@ -306,7 +306,7 @@ describe('urlMapper', function () {
expect(
mapper.stringify('/:foo', {
foo: 'bar',
bar: undefined,
bar: undefined
})
).toEqual('/bar')
})
Expand All @@ -320,8 +320,8 @@ describe('urlMapper', function () {
foo: true,
bar: 2,
baz: ['foo', 'bar', 'baz'],
e: '',
},
e: ''
}
}

// we do not test which url it stringified to
Expand Down Expand Up @@ -353,7 +353,7 @@ describe('urlMapper', function () {

expect(mapper.parse('/:foo/:bar?', '/bar/')).toEqual({
foo: 'bar',
bar: undefined,
bar: undefined
})
})
})
Expand Down

0 comments on commit 4409178

Please sign in to comment.