diff --git a/packages/sui-lint/src/RepositoryLinter/Match.js b/packages/sui-lint/src/RepositoryLinter/Match.js index ffb826b85..52f0373ba 100644 --- a/packages/sui-lint/src/RepositoryLinter/Match.js +++ b/packages/sui-lint/src/RepositoryLinter/Match.js @@ -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 diff --git a/packages/sui-lint/src/RepositoryLinter/Runner.js b/packages/sui-lint/src/RepositoryLinter/Runner.js index 8c3ffc81f..39e67d6f2 100644 --- a/packages/sui-lint/src/RepositoryLinter/Runner.js +++ b/packages/sui-lint/src/RepositoryLinter/Runner.js @@ -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) } } diff --git a/packages/sui-lint/test/server/MatchSpec.js b/packages/sui-lint/test/server/MatchSpec.js index 5db0c60c7..ebd3938fc 100644 --- a/packages/sui-lint/test/server/MatchSpec.js +++ b/packages/sui-lint/test/server/MatchSpec.js @@ -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 () { diff --git a/packages/sui-lint/test/server/RunnerSpec.js b/packages/sui-lint/test/server/RunnerSpec.js index 282c75406..06990d0db 100644 --- a/packages/sui-lint/test/server/RunnerSpec.js +++ b/packages/sui-lint/test/server/RunnerSpec.js @@ -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) + }) })