Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
doowb committed Aug 23, 2024
1 parent 67fcce6 commit 814f5f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ const braces = require('braces');
const picomatch = require('picomatch');
const utils = require('picomatch/lib/utils');

const isEmptyString = (v) => v === "" || v === "./";
const hasBraces = (v) => {
const index = v.indexOf("{");
return index > -1 && v.indexOf("}", index) > -1;
const isEmptyString = v => v === '' || v === './';
const hasBraces = v => {
const index = v.indexOf('{');
return index > -1 && v.indexOf('}', index) > -1;
};

/**
* Returns an array of strings that match one or more glob patterns.
*
Expand Down
29 changes: 14 additions & 15 deletions test/braces.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ const mm = require('..');
const { isMatch, hasBraces } = mm;

describe('braces', () => {
it("should return true when braces are found", () => {
assert.equal(hasBraces("{foo}"), true);
assert.equal(hasBraces("foo}"), false);
assert.equal(hasBraces("{foo"), false);
assert.equal(hasBraces("a{}b"), true);
assert.equal(hasBraces("abc {foo} xyz"), true);
assert.equal(hasBraces("abc {foo xyz"), false);
assert.equal(hasBraces("abc {foo} xyz"), true);
assert.equal(hasBraces("abc foo} xyz"), false);
assert.equal(hasBraces("abc foo xyz"), false);
assert.equal(hasBraces("abc {foo} xyz {bar} pqr"), true);
assert.equal(hasBraces("abc {foo xyz {bar} pqr"), true);
assert.equal(hasBraces("abc foo} xyz {bar pqr"), false);
});

it('should return true when braces are found', () => {
assert.equal(hasBraces('{foo}'), true);
assert.equal(hasBraces('foo}'), false);
assert.equal(hasBraces('{foo'), false);
assert.equal(hasBraces('a{}b'), true);
assert.equal(hasBraces('abc {foo} xyz'), true);
assert.equal(hasBraces('abc {foo xyz'), false);
assert.equal(hasBraces('abc {foo} xyz'), true);
assert.equal(hasBraces('abc foo} xyz'), false);
assert.equal(hasBraces('abc foo xyz'), false);
assert.equal(hasBraces('abc {foo} xyz {bar} pqr'), true);
assert.equal(hasBraces('abc {foo xyz {bar} pqr'), true);
assert.equal(hasBraces('abc foo} xyz {bar pqr'), false);
});

it('should handle extglobs in braces', () => {
let fixtures = ['a', 'b', 'c', 'd', 'ab', 'ac', 'ad', 'bc', 'cb', 'bc,d', 'c,db', 'c,d', 'd)', '(b|c', '*(b|c', 'b|c', 'b|cc', 'cb|c', 'x(a|b|c)', 'x(a|c)', '(a|b|c)', '(a|c)'];
Expand Down

0 comments on commit 814f5f7

Please sign in to comment.