Skip to content

Commit 57615f2

Browse files
author
tunnckoCore
committed
standard code style
1 parent be8e881 commit 57615f2

File tree

5 files changed

+137
-138
lines changed

5 files changed

+137
-138
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ language: node_js
33
node_js:
44
- "iojs"
55
- "0.10"
6-
- "0.11"
76
- "0.12"
8-
script: "npm run-script test-travis"
7+
script: "npm run-script travis"
98
after_script: "npm install coveralls && cat ./coverage/lcov.info | coveralls"

fixtures.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
'foo @bar~baz qux',
3737
'foo @bar|baz qux',
3838
'foo @bar"baz qux',
39-
'foo @bar\'baz qux',
39+
"foo @bar'baz qux",
4040

4141
'foo [email protected] qux',
4242
'foo ,@bar,baz qux',
@@ -60,7 +60,7 @@ module.exports = {
6060
'foo ~@bar~baz qux',
6161
'foo |@bar|baz qux',
6262
'foo "@bar"baz qux',
63-
'foo \'@bar\'baz qux'
63+
"foo '@bar'baz qux"
6464
],
6565
shouldNotMatch: [
6666
'foo bar@baz qux',
@@ -95,7 +95,7 @@ module.exports = {
9595
'foo @~bar~baz qux',
9696
'foo @|bar|baz qux',
9797
'foo @"bar"baz qux',
98-
'foo @\'bar\'baz qux',
98+
"foo @'bar'baz qux",
9999
'foo @.bar baz qux',
100100
'foo @,bar baz qux',
101101
'foo @!bar baz qux',
@@ -124,7 +124,7 @@ module.exports = {
124124
'foo @~bar baz qux',
125125
'foo @|bar baz qux',
126126
'foo @"bar baz qux',
127-
'foo @\'bar baz qux',
127+
"foo @'bar baz qux",
128128
'foo 2@222 baz qux',
129129
'foo 2@bar baz qux',
130130
'foo !@bar!baz qux',
@@ -136,4 +136,4 @@ module.exports = {
136136
'foo _@bar_baz qux',
137137
'foo _@bar baz qux'
138138
]
139-
};
139+
}

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Released under the MIT license.
66
*/
77

8-
'use strict';
8+
'use strict'
99

1010
/**
1111
* Compatible twitter mentions regex, not only of course!
@@ -15,11 +15,11 @@
1515
* @return {RegExp}
1616
* @api public
1717
*/
18-
module.exports = function mentionsRegex(dot) {
18+
module.exports = function mentionsRegex (dot) {
1919
if (dot) {
2020
// e.g. @google.com will match `google.com`
21-
return /(?:^|[^a-zA-Z0-9_!@#$%&*])(?:(?:@|)(?!\/))([a-zA-Z0-9/_.]{1,15})(?:\b(?!@|)|$)/;
21+
return /(?:^|[^a-zA-Z0-9_!@#$%&*])(?:(?:@|)(?!\/))([a-zA-Z0-9/_.]{1,15})(?:\b(?!@|)|$)/
2222
}
2323
// e.g. @google.com will match `google`
24-
return /(?:^|[^a-zA-Z0-9_!@#$%&*])(?:(?:@|)(?!\/))([a-zA-Z0-9/_]{1,15})(?:\b(?!@|)|$)/;
25-
};
24+
return /(?:^|[^a-zA-Z0-9_!@#$%&*])(?:(?:@|)(?!\/))([a-zA-Z0-9/_]{1,15})(?:\b(?!@|)|$)/
25+
}

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"version": "2.0.2",
44
"description": "100% twitter compatible `@mentions` regex! Regular expression for matching `@username` mentions, as used on twitter, facebook, github, etc.",
55
"scripts": {
6-
"test": "mocha",
7-
"test-cov": "istanbul cover _mocha",
8-
"test-travis": "istanbul cover _mocha --report lcovonly"
6+
"test": "standard && node test.js",
7+
"travis": "standard && istanbul cover test.js --report lcovonly"
98
},
109
"author": {
1110
"name": "Charlike Mike Reagent",
@@ -39,7 +38,8 @@
3938
},
4039
"dependencies": {},
4140
"devDependencies": {
42-
"istanbul": "~0.3.11",
43-
"mocha": "~2.2.1"
41+
"assertit": "^0.1.0",
42+
"istanbul": "^0.3.9",
43+
"standard": "^3.7.3"
4444
}
45-
}
45+
}

test.js

Lines changed: 120 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -5,129 +5,129 @@
55
* Released under the MIT license.
66
*/
77

8-
'use strict';
8+
'use strict'
99

10-
var assert = require('assert');
11-
var regexp = require('./index');
12-
var fixtures = require('./fixtures');
10+
var test = require('assertit')
11+
var regexp = require('./index')
12+
var fixtures = require('./fixtures')
1313

14-
function match(str, dot) {
15-
var ex = regexp(dot).exec(str);
16-
return ex && ex[1] || null;
14+
function reMatch (str, dot) {
15+
var ex = regexp(dot).exec(str)
16+
return ex && ex[1] || null
1717
}
1818

19-
function test(str, dot) {
20-
return regexp(dot).test(str);
19+
function reTest (str, dot) {
20+
return regexp(dot).test(str)
2121
}
2222

23-
describe('mentions-regex:', function() {
24-
describe('when `dot` is true', function() {
25-
it('should match `google.com` from `foo @google.com bar`', function(done) {
26-
assert.strictEqual(match('foo @google.com bar', true), 'google.com');
27-
assert.strictEqual(test('foo @google.com bar', true), true);
28-
done();
29-
});
30-
31-
it('should not match when `[email protected] qux`', function(done) {
32-
assert.strictEqual(match('[email protected] qux', true), null);
33-
assert.strictEqual(test('[email protected] qux', true), false);
34-
done();
35-
});
36-
});
37-
38-
describe('when `dot` is falsey value', function() {
39-
it('should match `google` from `foo @google.com bar`', function(done) {
40-
assert.strictEqual(match('foo @google.com bar', false), 'google');
41-
assert.strictEqual(test('foo @google.com bar', false), true);
42-
done();
43-
});
44-
45-
it('should not match when `[email protected] qux`', function(done) {
46-
assert.strictEqual(match('[email protected] qux', false), null);
47-
assert.strictEqual(test('[email protected] qux', false), false);
48-
done();
49-
});
50-
});
51-
52-
describe('special cases', function() {
53-
it('should match `bar_baz` from `foo @bar_baz qux`', function(done) {
54-
assert.strictEqual(match('foo @bar_baz qux'), 'bar_baz');
55-
assert.strictEqual(test('foo @bar_baz qux'), true);
56-
done();
57-
});
58-
59-
it('should match `_bar_baz` from `foo @_bar_baz qux`', function(done) {
60-
assert.strictEqual(match('foo @_bar_baz qux'), '_bar_baz');
61-
assert.strictEqual(test('foo @_bar_baz qux'), true);
62-
done();
63-
});
64-
65-
it('should match `_bar` from `foo @_bar baz qux`', function(done) {
66-
assert.strictEqual(match('foo @_bar baz qux'), '_bar');
67-
assert.strictEqual(test('foo @_bar baz qux'), true);
68-
done();
69-
});
70-
71-
it('should match `bar/baz` from `foo @bar/baz qux`', function(done) {
72-
assert.strictEqual(match('foo @bar/baz qux'), 'bar/baz');
73-
assert.strictEqual(test('foo @bar/baz qux'), true);
74-
done();
75-
});
76-
77-
it('should match `bar/baz` from `foo /@bar/baz qux`', function(done) {
78-
assert.strictEqual(match('foo /@bar/baz qux'), 'bar/baz');
79-
assert.strictEqual(test('foo /@bar/baz qux'), true);
80-
done();
81-
});
82-
83-
it('should match `bar` from `foo /@bar baz qux`', function(done) {
84-
assert.strictEqual(match('foo /@bar baz qux'), 'bar');
85-
assert.strictEqual(test('foo /@bar baz qux'), true);
86-
done();
87-
});
88-
89-
it('should match `222` from `foo @222 baz qux`', function(done) {
90-
assert.strictEqual(match('foo @222 baz qux'), '222');
91-
assert.strictEqual(test('foo @222 baz qux'), true);
92-
done();
93-
});
94-
95-
it('should not match from `foo @/bar/baz qux`', function(done) {
96-
assert.strictEqual(match('foo @/bar/baz qux'), null);
97-
assert.strictEqual(test('foo @/bar/baz qux'), false);
98-
done();
99-
});
100-
101-
it('should not match from `foo @/bar baz qux`', function(done) {
102-
assert.strictEqual(match('foo @/bar baz qux'), null);
103-
assert.strictEqual(test('foo @/bar baz qux'), false);
104-
done();
105-
});
106-
107-
it('should not match email addresses `[email protected]`', function(done) {
108-
assert.strictEqual(match('[email protected]'), null);
109-
assert.strictEqual(test('[email protected]'), false);
110-
done();
111-
});
112-
});
113-
114-
describe('should match `bar` only', function() {
115-
fixtures.shouldMatchBarOnly.forEach(function _each(item) {
116-
it('from `' + item + '` string given', function(done) {
117-
assert.strictEqual(match(item), 'bar');
118-
assert.strictEqual(test(item), true);
119-
done();
120-
});
121-
});
122-
});
123-
124-
describe('should not match', function() {
125-
fixtures.shouldNotMatch.forEach(function _each(item) {
126-
it('from `' + item + '` string given', function(done) {
127-
assert.strictEqual(match(item), null);
128-
assert.strictEqual(test(item), false);
129-
done();
130-
});
131-
});
132-
});
133-
});
23+
test('mentions-regex:', function () {
24+
test('when `dot` is true', function () {
25+
test('should match `google.com` from `foo @google.com bar`', function (done) {
26+
test.equal(reMatch('foo @google.com bar', true), 'google.com')
27+
test.equal(reTest('foo @google.com bar', true), true)
28+
done()
29+
})
30+
31+
test('should not match when `[email protected] qux`', function (done) {
32+
test.equal(reMatch('[email protected] qux', true), null)
33+
test.equal(reTest('[email protected] qux', true), false)
34+
done()
35+
})
36+
})
37+
38+
test('when `dot` is falsey value', function () {
39+
test('should match `google` from `foo @google.com bar`', function (done) {
40+
test.equal(reMatch('foo @google.com bar', false), 'google')
41+
test.equal(reTest('foo @google.com bar', false), true)
42+
done()
43+
})
44+
45+
test('should not match when `[email protected] qux`', function (done) {
46+
test.equal(reMatch('[email protected] qux', false), null)
47+
test.equal(reTest('[email protected] qux', false), false)
48+
done()
49+
})
50+
})
51+
52+
test('special cases', function () {
53+
test('should match `bar_baz` from `foo @bar_baz qux`', function (done) {
54+
test.equal(reMatch('foo @bar_baz qux'), 'bar_baz')
55+
test.equal(reTest('foo @bar_baz qux'), true)
56+
done()
57+
})
58+
59+
test('should match `_bar_baz` from `foo @_bar_baz qux`', function (done) {
60+
test.equal(reMatch('foo @_bar_baz qux'), '_bar_baz')
61+
test.equal(reTest('foo @_bar_baz qux'), true)
62+
done()
63+
})
64+
65+
test('should match `_bar` from `foo @_bar baz qux`', function (done) {
66+
test.equal(reMatch('foo @_bar baz qux'), '_bar')
67+
test.equal(reTest('foo @_bar baz qux'), true)
68+
done()
69+
})
70+
71+
test('should match `bar/baz` from `foo @bar/baz qux`', function (done) {
72+
test.equal(reMatch('foo @bar/baz qux'), 'bar/baz')
73+
test.equal(reTest('foo @bar/baz qux'), true)
74+
done()
75+
})
76+
77+
test('should match `bar/baz` from `foo /@bar/baz qux`', function (done) {
78+
test.equal(reMatch('foo /@bar/baz qux'), 'bar/baz')
79+
test.equal(reTest('foo /@bar/baz qux'), true)
80+
done()
81+
})
82+
83+
test('should match `bar` from `foo /@bar baz qux`', function (done) {
84+
test.equal(reMatch('foo /@bar baz qux'), 'bar')
85+
test.equal(reTest('foo /@bar baz qux'), true)
86+
done()
87+
})
88+
89+
test('should match `222` from `foo @222 baz qux`', function (done) {
90+
test.equal(reMatch('foo @222 baz qux'), '222')
91+
test.equal(reTest('foo @222 baz qux'), true)
92+
done()
93+
})
94+
95+
test('should not match from `foo @/bar/baz qux`', function (done) {
96+
test.equal(reMatch('foo @/bar/baz qux'), null)
97+
test.equal(reTest('foo @/bar/baz qux'), false)
98+
done()
99+
})
100+
101+
test('should not match from `foo @/bar baz qux`', function (done) {
102+
test.equal(reMatch('foo @/bar baz qux'), null)
103+
test.equal(reTest('foo @/bar baz qux'), false)
104+
done()
105+
})
106+
107+
test('should not match email addresses `[email protected]`', function (done) {
108+
test.equal(reMatch('[email protected]'), null)
109+
test.equal(reTest('[email protected]'), false)
110+
done()
111+
})
112+
})
113+
114+
test('should match `bar` only', function () {
115+
fixtures.shouldMatchBarOnly.forEach(function _each (item) {
116+
test('from `' + item + '` string given', function (done) {
117+
test.equal(reMatch(item), 'bar')
118+
test.equal(reTest(item), true)
119+
done()
120+
})
121+
})
122+
})
123+
124+
test('should not match', function () {
125+
fixtures.shouldNotMatch.forEach(function _each (item) {
126+
test('from `' + item + '` string given', function (done) {
127+
test.equal(reMatch(item), null)
128+
test.equal(reTest(item), false)
129+
done()
130+
})
131+
})
132+
})
133+
})

0 commit comments

Comments
 (0)