Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/sui-lint/src/RepositoryLinter/Match.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class Match {

static create(path) {
const ext = extname(path)
if (!ext && CustomFileReader.create().isDirectory(path)) {
return new Match(path, undefined, undefined, true)
if (CustomFileReader.create().isDirectory(path)) {
return new Match(path, undefined, '', true)
}

let parsed
Expand Down
2 changes: 1 addition & 1 deletion packages/sui-lint/src/RepositoryLinter/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports.Runner = class Runner {
}

assertion(key) {
const files = this.fg.sync(key, {ignore: ['node_modules'], onlyFiles: false}) ?? []
const files = this.fg.sync(key, {ignore: ['**/node_modules/**'], onlyFiles: false}) ?? []
return files.map(Match.create)
}
}
14 changes: 14 additions & 0 deletions packages/sui-lint/test/server/MatchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ describe('Match', function () {

// Then
expect(match.isDir).to.be.eqls(true)
expect(match.raw).to.be.eqls('')
})

it('Should detect directories with file-like extensions', function () {
// Given
this.isDirStub.returns(true)

// When
const match = Match.create('cypress/screenshots/PTA/CategoryPicker.js')

// Then
expect(match.isDir).to.be.eqls(true)
expect(match.raw).to.be.eqls('')
expect(match.raw.match(/pattern/)).to.be.eqls(null)
})

it('Should detect files w/out extensions', function () {
Expand Down
16 changes: 16 additions & 0 deletions packages/sui-lint/test/server/RunnerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ describe('Runner', function () {
expect(this.matchCreateStub.firstCall.firstArg).to.be.eql('path/file.json')
expect(this.syncStub.firstCall.firstArg).to.be.eql('**/*.json')
})

it('Should ignore node_modules at any depth', function () {
this.syncStub.returns([])

Runner.create({sync: this.syncStub}).assertion('**/*.js')

expect(this.syncStub.firstCall.args[1].ignore).to.be.eql(['**/node_modules/**'])
})

it('Should include directories in results', function () {
this.syncStub.returns(['app/src'])

Runner.create({sync: this.syncStub}).assertion('app/src')

expect(this.syncStub.firstCall.args[1].onlyFiles).to.be.eql(false)
})
})
Loading