diff --git a/README.md b/README.md index 47f76d6..910f761 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# textlint-rule-ignore-comments [![Build Status](https://travis-ci.org/textlint/textlint-rule-ignore-comment.svg?branch=master)](https://travis-ci.org/textlint/textlint-rule-ignore-comment) +# textlint-filter-rule-comments [![Build Status](https://travis-ci.org/textlint/textlint-filter-rule-comments.svg?branch=master)](https://travis-ci.org/textlint/textlint-filter-rule-comments) textlint rule that ignore texts using comments directive. @@ -6,11 +6,11 @@ textlint rule that ignore texts using comments directive. Install with [npm](https://www.npmjs.com/): - npm install textlint-rule-ignore-comments + npm install textlint-filter-rule-comments Dependencies: -- [textlint](http://textlint.github.io/ "textlint") >= 6.8 +- [textlint](http://textlint.github.io/ "textlint") >= 6.9 ## Usage @@ -115,7 +115,7 @@ textlint --rule ignore-comments README.md ## Changelog -See [Releases page](https://github.com/textlint/textlint-rule-ignore-comments/releases). +See [Releases page](https://github.com/textlint/textlint-filter-rule-comments/releases). ## Acknowledgement @@ -130,7 +130,7 @@ Install devDependencies and Run `npm test`: ## Contributing Pull requests and stars are always welcome. -For bugs and feature requests, [please create an issue](https://github.com/textlint/textlint-rule-ignore-comments/issues). +For bugs and feature requests, [please create an issue](https://github.com/textlint/textlint-filter-rule-comments/issues). 1. Fork it! 2. Create your feature branch: `git checkout -b my-new-feature` diff --git a/package.json b/package.json index 38a4b49..0f44975 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { - "name": "textlint-rule-ignore-comments", + "name": "textlint-filter-rule-comments", "repository": { "type": "git", - "url": "https://github.com/textlint/textlint-rule-ignore-comments.git" + "url": "https://github.com/textlint/textlint-filter-rule-comments.git" }, "author": "azu", "email": "azuciao@gmail.com", - "homepage": "https://github.com/textlint/textlint-rule-ignore-comments", + "homepage": "https://github.com/textlint/textlint-filter-rule-comments", "license": "MIT", "bugs": { - "url": "https://github.com/textlint/textlint-rule-ignore-comments/issues" + "url": "https://github.com/textlint/textlint-filter-rule-comments/issues" }, "files": [ "src/", @@ -17,7 +17,7 @@ ], "version": "1.1.0", "description": "textlint rule that ignore texts using comments directive.", - "main": "lib/textlint-rule-ignore-comments.js", + "main": "lib/textlint-filter-rule-comments.js", "directories": { "test": "test" }, @@ -40,7 +40,7 @@ "mocha": "^2.4.5", "power-assert": "^1.4.0", "textlint": "^6.8.0", - "textlint-rule-report-node-types": "^1.0.1" + "textlint-rule-report-node-types": "^1.1.0" }, "peerDependencies": { "textlint": ">=6.8.0" diff --git a/src/textlint-rule-ignore-comments.js b/src/textlint-filter-rule-comments.js similarity index 100% rename from src/textlint-rule-ignore-comments.js rename to src/textlint-filter-rule-comments.js diff --git a/test/textlint-filter-rule-comments-fix-test.js b/test/textlint-filter-rule-comments-fix-test.js new file mode 100644 index 0000000..0ea8291 --- /dev/null +++ b/test/textlint-filter-rule-comments-fix-test.js @@ -0,0 +1,157 @@ +// LICENSE : MIT +"use strict"; +const TextLintCore = require("textlint").TextLintCore; +const TextLintNodeType = require("textlint").TextLintNodeType; +const filterRule = require("../src/textlint-filter-rule-comments"); +const reportRule = require("textlint-rule-report-node-types"); +const assert = require("power-assert"); +describe.skip("textlint-rule-ignore-node-types --fix", function () { + context("no options", function () { + context("when before textlint-enable", function () { + it("should not ignored", function () { + const textlint = new TextLintCore(); + textlint.setupRules({ + ignore: filterRule, + report: reportRule + }, { + report: { + nodeTypes: [TextLintNodeType.Str] + } + }); + return textlint.fixText(` +This is Error. + + + +This is ignored. + + +`, ".md").then(({messages}) => { + console.log(messages); + assert.equal(messages.length, 1); + }); + }); + }); + context("when during disable -- enable", function () { + it("should messages is ignored between disable and enable", function () { + const textlint = new TextLintCore(); + textlint.setupRules({ + ignore: filterRule, + report: reportRule + }, { + report: { + nodeTypes: [TextLintNodeType.Str] + } + }); + return textlint.fixText(` + + +This is text. + + +`, ".md").then(({messages}) => { + assert.equal(messages.length, 0); + }); + }); + }); + context("when after textlint-enable", function () { + it("should not ignored", function () { + const textlint = new TextLintCore(); + textlint.setupRules({ + ignore: filterRule, + report: reportRule + }, { + report: { + nodeTypes: [TextLintNodeType.Str] + } + }); + return textlint.fixText(` + + + +This is ignored. + + + +This is Error. +`, ".md").then(({messages}) => { + assert.equal(messages.length, 1); + }); + }); + }); + }); + context("with ruleId options", function () { + context("when disable ", function () { + it("should ignore messages of ruleA", function () { + const textlint = new TextLintCore(); + textlint.setupRules({ + ignore: filterRule, + ruleA: reportRule + }, { + ruleA: { + nodeTypes: [TextLintNodeType.Str] + } + }); + return textlint.fixText(` + + +This is text. + + +`, ".md").then(({messages}) => { + assert.equal(messages.length, 0); + }); + }); + it("should not ignore messages of other rules", function () { + const textlint = new TextLintCore(); + textlint.setupRules({ + ignore: filterRule, + ruleX: reportRule + }, { + ruleX: { + nodeTypes: [TextLintNodeType.Str] + } + }); + return textlint.fixText(` + + +This is text. + + +`, ".md").then(({messages}) => { + assert.equal(messages.length, 1); + }); + }); + }); + context("after textlint-enable ", function () { + it("should ignore messages of ruleA", function () { + const textlint = new TextLintCore(); + textlint.setupRules({ + ignore: filterRule, + ruleA: reportRule, + ruleB: reportRule + }, { + ruleA: { + nodeTypes: [TextLintNodeType.Str] + }, + ruleB: { + nodeTypes: [TextLintNodeType.Str] + } + }); + return textlint.fixText(` + + + +This is ignored. RuleA and RuleB + + + +This is Error of RuleA. + +`, ".md").then(({messages}) => { + assert.equal(messages.length, 1); + }); + }); + }); + }); +}); \ No newline at end of file diff --git a/test/textlint-rule-ignore-comments-test.js b/test/textlint-filter-rule-comments-test.js similarity index 93% rename from test/textlint-rule-ignore-comments-test.js rename to test/textlint-filter-rule-comments-test.js index e50356f..940802c 100644 --- a/test/textlint-rule-ignore-comments-test.js +++ b/test/textlint-filter-rule-comments-test.js @@ -2,7 +2,7 @@ "use strict"; const TextLintCore = require("textlint").TextLintCore; const TextLintNodeType = require("textlint").TextLintNodeType; -const ignoreRule = require("../src/textlint-rule-ignore-comments"); +const filterRule = require("../src/textlint-filter-rule-comments"); const reportRule = require("textlint-rule-report-node-types"); const assert = require("power-assert"); describe("textlint-rule-ignore-node-types", function () { @@ -11,7 +11,7 @@ describe("textlint-rule-ignore-node-types", function () { it("should not ignored", function () { const textlint = new TextLintCore(); textlint.setupRules({ - ignore: ignoreRule, + ignore: filterRule, report: reportRule }, { report: { @@ -35,7 +35,7 @@ This is ignored. it("should messages is ignored between disable and enable", function () { const textlint = new TextLintCore(); textlint.setupRules({ - ignore: ignoreRule, + ignore: filterRule, report: reportRule }, { report: { @@ -57,7 +57,7 @@ This is text. it("should not ignored", function () { const textlint = new TextLintCore(); textlint.setupRules({ - ignore: ignoreRule, + ignore: filterRule, report: reportRule }, { report: { @@ -84,7 +84,7 @@ This is Error. it("should ignore messages of ruleA", function () { const textlint = new TextLintCore(); textlint.setupRules({ - ignore: ignoreRule, + ignore: filterRule, ruleA: reportRule }, { ruleA: { @@ -104,7 +104,7 @@ This is text. it("should not ignore messages of other rules", function () { const textlint = new TextLintCore(); textlint.setupRules({ - ignore: ignoreRule, + ignore: filterRule, ruleX: reportRule }, { ruleX: { @@ -126,7 +126,7 @@ This is text. it("should ignore messages of ruleA", function () { const textlint = new TextLintCore(); textlint.setupRules({ - ignore: ignoreRule, + ignore: filterRule, ruleA: reportRule, ruleB: reportRule }, {