Skip to content

Commit 81b3ecd

Browse files
committed
catch hashbang: false
1 parent f72621c commit 81b3ecd

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

rules/vue-router/hashbang-false.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict'
2+
3+
var chalk = require('chalk')
4+
5+
module.exports = {
6+
pattern: /\bhashbang\s*?:/,
7+
warning: function (match) {
8+
return {
9+
reason: 'Hashbangs are no longer required for Google to crawl a URL, so they are no longer the default (or even an option) for the hash strategy',
10+
fix: (
11+
'Remove the ' + chalk.red('hashbang') + ' option'
12+
),
13+
docsHash: 'hashbang-false-deprecated'
14+
}
15+
}
16+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict'
2+
3+
const check = createRuleChecker('vue-router/hashbang-false')
4+
5+
describe('Rule: hashbang-false', () => {
6+
it('does not match an empty line', () => {
7+
const warning = check('')
8+
expect(warning).toBe(null)
9+
})
10+
11+
it('does not match "can reuse"', () => {
12+
const warning = check('can reuse')
13+
expect(warning).toBe(null)
14+
})
15+
16+
it('does not match "hashbang"', () => {
17+
const warning = check('hashbang')
18+
expect(warning).toBe(null)
19+
})
20+
21+
it('matches "hashbang:"', () => {
22+
const warning = check(`
23+
hashbang:
24+
`)
25+
expect(warning).toBeTruthy()
26+
expect(warning.fix).toBe('Remove the hashbang option')
27+
})
28+
29+
it('matches "hashbang :"', () => {
30+
const warning = check(`
31+
hashbang :
32+
`)
33+
expect(warning).toBeTruthy()
34+
expect(warning.fix).toBe('Remove the hashbang option')
35+
})
36+
})

0 commit comments

Comments
 (0)