diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a7a1c5a..d33f8a19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * `async` was added to the function interface. * Major changes have been make to the [JSON Formatter](index.js) to accommodate the structure change of `LintResult`. * Non top-level configuration support (ex. `targetdir/otherdir/repolinter.json` would trigger another lint of `otherdir`) has been removed for now. + * Renamed several rule options to more clearly convey functionality (`files` -> `globsAny`) and remove problematic language (`blacklist` -> `denylist`). Backwards compatibility for old property names in version 1 rulesets is still maintained, however the schema will fail to validate in version 2. * Some slight changes have been made to the default formatter to accommodate the feature list below. ### Features diff --git a/rules/git-grep-commits.js b/rules/git-grep-commits.js index 2d817022..c9f6d309 100644 --- a/rules/git-grep-commits.js +++ b/rules/git-grep-commits.js @@ -89,6 +89,9 @@ function listFiles (fileSystem, options) { * @returns {Result} The lint rule result */ function gitGrepCommits (fs, options) { + // backwards compatibility with blacklist + options.denylist = options.denylist || options.blacklist + const files = listFiles(fs, options) const targets = files.map(file => { const [firstCommit, ...rest] = file.commits diff --git a/rules/git-grep-log.js b/rules/git-grep-log.js index ed1d9cc6..ae3519de 100644 --- a/rules/git-grep-log.js +++ b/rules/git-grep-log.js @@ -43,6 +43,9 @@ function extractInfo (commit) { * @returns {Result} The lint rule result */ function gitGrepLog (fs, options) { + // backwards compatibility with blacklist + options.denylist = options.denylist || options.blacklist + const commits = grepLog(fs, options) const targets = commits.map(commit => { diff --git a/rules/git-list-tree.js b/rules/git-list-tree.js index 15501582..e902d315 100644 --- a/rules/git-list-tree.js +++ b/rules/git-list-tree.js @@ -53,6 +53,9 @@ function listFiles (fileSystem, options) { * @returns {Result} The lint rule result */ function gitListTree (fs, options) { + // backwards compatibility with blacklist + options.denylist = options.denylist || options.blacklist + const files = listFiles(fs, options) const targets = files.map(file => { diff --git a/tests/rules/git_grep_commits_tests.js b/tests/rules/git_grep_commits_tests.js index 49803d67..15a7c3ed 100644 --- a/tests/rules/git_grep_commits_tests.js +++ b/tests/rules/git_grep_commits_tests.js @@ -31,6 +31,18 @@ describe('rule', () => { expect(actual.message).to.contain(ruleopts.denylist[0]) }) + it('is backwards compatible with blacklist', () => { + const ruleopts = { + blacklist: [DIFF_WRONG_CASE], + ignoreCase: false + } + + const actual = gitGrepCommits(new FileSystem(), ruleopts) + + expect(actual.passed).to.equal(true) + expect(actual.message).to.contain(ruleopts.blacklist[0]) + }) + it('fails if the denylist pattern matches a commit', () => { const ruleopts = { denylist: [DIFF_CORRECT_CASE], diff --git a/tests/rules/git_grep_log_tests.js b/tests/rules/git_grep_log_tests.js index b6c715ed..5ca93755 100644 --- a/tests/rules/git_grep_log_tests.js +++ b/tests/rules/git_grep_log_tests.js @@ -27,6 +27,19 @@ describe('rule', () => { expect(actual.message).to.contain(ruleopts.denylist[0]) }) + it('is backwards compatible with blacklist', () => { + const ruleopts = { + blacklist: [LOG_WRONG_CASE], + ignoreCase: false + } + + const actual = gitGrepLog(new FileSystem(), ruleopts) + + expect(actual.passed).to.equal(true) + expect(actual.targets).to.have.length(0) + expect(actual.message).to.contain(ruleopts.blacklist[0]) + }) + it('fails if the denylist pattern matches a commit message', () => { const ruleopts = { denylist: [LOG_WRONG_CASE], diff --git a/tests/rules/git_list_tree_tests.js b/tests/rules/git_list_tree_tests.js index 1816bd8c..0eda85be 100644 --- a/tests/rules/git_list_tree_tests.js +++ b/tests/rules/git_list_tree_tests.js @@ -28,6 +28,18 @@ describe('rule', () => { expect(actual.targets).to.have.length(0) }) + it('is backwards compatible with blacklist', () => { + const ruleopts = { + blacklist: [PATH_WRONG_CASE], + ignoreCase: false + } + + const actual = gitListTree(new FileSystem(), ruleopts) + + expect(actual.passed).to.equal(true) + expect(actual.targets).to.have.length(0) + }) + it('fails if the denylist pattern matches a path', () => { const ruleopts = { denylist: [PATH_WRONG_CASE],