Skip to content

Commit d045284

Browse files
committed
Rename to textlint-filter-rule-comments (#2)
* test(fixer): add test * Breaking Change(npm): rename to textlint-filter-rule-comments * chore(readme): fix name of travis
1 parent a423c73 commit d045284

5 files changed

+175
-18
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# 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)
1+
# 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)
22

33
textlint rule that ignore texts using comments directive.
44

55
## Install
66

77
Install with [npm](https://www.npmjs.com/):
88

9-
npm install textlint-rule-ignore-comments
9+
npm install textlint-filter-rule-comments
1010

1111
Dependencies:
1212

13-
- [textlint](http://textlint.github.io/ "textlint") >= 6.8
13+
- [textlint](http://textlint.github.io/ "textlint") >= 6.9
1414

1515
## Usage
1616

@@ -115,7 +115,7 @@ textlint --rule ignore-comments README.md
115115

116116
## Changelog
117117

118-
See [Releases page](https://github.com/textlint/textlint-rule-ignore-comments/releases).
118+
See [Releases page](https://github.com/textlint/textlint-filter-rule-comments/releases).
119119

120120
## Acknowledgement
121121

@@ -130,7 +130,7 @@ Install devDependencies and Run `npm test`:
130130
## Contributing
131131

132132
Pull requests and stars are always welcome.
133-
For bugs and feature requests, [please create an issue](https://github.com/textlint/textlint-rule-ignore-comments/issues).
133+
For bugs and feature requests, [please create an issue](https://github.com/textlint/textlint-filter-rule-comments/issues).
134134

135135
1. Fork it!
136136
2. Create your feature branch: `git checkout -b my-new-feature`

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"name": "textlint-rule-ignore-comments",
2+
"name": "textlint-filter-rule-comments",
33
"repository": {
44
"type": "git",
5-
"url": "https://github.com/textlint/textlint-rule-ignore-comments.git"
5+
"url": "https://github.com/textlint/textlint-filter-rule-comments.git"
66
},
77
"author": "azu",
88
"email": "[email protected]",
9-
"homepage": "https://github.com/textlint/textlint-rule-ignore-comments",
9+
"homepage": "https://github.com/textlint/textlint-filter-rule-comments",
1010
"license": "MIT",
1111
"bugs": {
12-
"url": "https://github.com/textlint/textlint-rule-ignore-comments/issues"
12+
"url": "https://github.com/textlint/textlint-filter-rule-comments/issues"
1313
},
1414
"files": [
1515
"src/",
1616
"lib/"
1717
],
1818
"version": "1.1.0",
1919
"description": "textlint rule that ignore texts using comments directive.",
20-
"main": "lib/textlint-rule-ignore-comments.js",
20+
"main": "lib/textlint-filter-rule-comments.js",
2121
"directories": {
2222
"test": "test"
2323
},
@@ -40,7 +40,7 @@
4040
"mocha": "^2.4.5",
4141
"power-assert": "^1.4.0",
4242
"textlint": "^6.8.0",
43-
"textlint-rule-report-node-types": "^1.0.1"
43+
"textlint-rule-report-node-types": "^1.1.0"
4444
},
4545
"peerDependencies": {
4646
"textlint": ">=6.8.0"
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// LICENSE : MIT
2+
"use strict";
3+
const TextLintCore = require("textlint").TextLintCore;
4+
const TextLintNodeType = require("textlint").TextLintNodeType;
5+
const filterRule = require("../src/textlint-filter-rule-comments");
6+
const reportRule = require("textlint-rule-report-node-types");
7+
const assert = require("power-assert");
8+
describe.skip("textlint-rule-ignore-node-types --fix", function () {
9+
context("no options", function () {
10+
context("when before textlint-enable", function () {
11+
it("should not ignored", function () {
12+
const textlint = new TextLintCore();
13+
textlint.setupRules({
14+
ignore: filterRule,
15+
report: reportRule
16+
}, {
17+
report: {
18+
nodeTypes: [TextLintNodeType.Str]
19+
}
20+
});
21+
return textlint.fixText(`
22+
This is Error.
23+
24+
<!-- textlint-disable -->
25+
26+
This is ignored.
27+
28+
<!-- textlint-enable -->
29+
`, ".md").then(({messages}) => {
30+
console.log(messages);
31+
assert.equal(messages.length, 1);
32+
});
33+
});
34+
});
35+
context("when during disable -- enable", function () {
36+
it("should messages is ignored between disable and enable", function () {
37+
const textlint = new TextLintCore();
38+
textlint.setupRules({
39+
ignore: filterRule,
40+
report: reportRule
41+
}, {
42+
report: {
43+
nodeTypes: [TextLintNodeType.Str]
44+
}
45+
});
46+
return textlint.fixText(`
47+
<!-- textlint-disable -->
48+
49+
This is text.
50+
51+
<!-- textlint-enable -->
52+
`, ".md").then(({messages}) => {
53+
assert.equal(messages.length, 0);
54+
});
55+
});
56+
});
57+
context("when after textlint-enable", function () {
58+
it("should not ignored", function () {
59+
const textlint = new TextLintCore();
60+
textlint.setupRules({
61+
ignore: filterRule,
62+
report: reportRule
63+
}, {
64+
report: {
65+
nodeTypes: [TextLintNodeType.Str]
66+
}
67+
});
68+
return textlint.fixText(`
69+
70+
<!-- textlint-disable -->
71+
72+
This is ignored.
73+
74+
<!-- textlint-enable -->
75+
76+
This is Error.
77+
`, ".md").then(({messages}) => {
78+
assert.equal(messages.length, 1);
79+
});
80+
});
81+
});
82+
});
83+
context("with ruleId options", function () {
84+
context("when disable <ruleA>", function () {
85+
it("should ignore messages of ruleA", function () {
86+
const textlint = new TextLintCore();
87+
textlint.setupRules({
88+
ignore: filterRule,
89+
ruleA: reportRule
90+
}, {
91+
ruleA: {
92+
nodeTypes: [TextLintNodeType.Str]
93+
}
94+
});
95+
return textlint.fixText(`
96+
<!-- textlint-disable ruleA -->
97+
98+
This is text.
99+
100+
<!-- textlint-enable ruleA -->
101+
`, ".md").then(({messages}) => {
102+
assert.equal(messages.length, 0);
103+
});
104+
});
105+
it("should not ignore messages of other rules", function () {
106+
const textlint = new TextLintCore();
107+
textlint.setupRules({
108+
ignore: filterRule,
109+
ruleX: reportRule
110+
}, {
111+
ruleX: {
112+
nodeTypes: [TextLintNodeType.Str]
113+
}
114+
});
115+
return textlint.fixText(`
116+
<!-- textlint-disable ruleA -->
117+
118+
This is text.
119+
120+
<!-- textlint-enable -->
121+
`, ".md").then(({messages}) => {
122+
assert.equal(messages.length, 1);
123+
});
124+
});
125+
});
126+
context("after textlint-enable <ruleA>", function () {
127+
it("should ignore messages of ruleA", function () {
128+
const textlint = new TextLintCore();
129+
textlint.setupRules({
130+
ignore: filterRule,
131+
ruleA: reportRule,
132+
ruleB: reportRule
133+
}, {
134+
ruleA: {
135+
nodeTypes: [TextLintNodeType.Str]
136+
},
137+
ruleB: {
138+
nodeTypes: [TextLintNodeType.Str]
139+
}
140+
});
141+
return textlint.fixText(`
142+
143+
<!-- textlint-disable ruleA,ruleB -->
144+
145+
This is ignored. RuleA and RuleB
146+
147+
<!-- textlint-enable ruleA -->
148+
149+
This is Error of RuleA.
150+
151+
`, ".md").then(({messages}) => {
152+
assert.equal(messages.length, 1);
153+
});
154+
});
155+
});
156+
});
157+
});

test/textlint-rule-ignore-comments-test.js test/textlint-filter-rule-comments-test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"use strict";
33
const TextLintCore = require("textlint").TextLintCore;
44
const TextLintNodeType = require("textlint").TextLintNodeType;
5-
const ignoreRule = require("../src/textlint-rule-ignore-comments");
5+
const filterRule = require("../src/textlint-filter-rule-comments");
66
const reportRule = require("textlint-rule-report-node-types");
77
const assert = require("power-assert");
88
describe("textlint-rule-ignore-node-types", function () {
@@ -11,7 +11,7 @@ describe("textlint-rule-ignore-node-types", function () {
1111
it("should not ignored", function () {
1212
const textlint = new TextLintCore();
1313
textlint.setupRules({
14-
ignore: ignoreRule,
14+
ignore: filterRule,
1515
report: reportRule
1616
}, {
1717
report: {
@@ -35,7 +35,7 @@ This is ignored.
3535
it("should messages is ignored between disable and enable", function () {
3636
const textlint = new TextLintCore();
3737
textlint.setupRules({
38-
ignore: ignoreRule,
38+
ignore: filterRule,
3939
report: reportRule
4040
}, {
4141
report: {
@@ -57,7 +57,7 @@ This is text.
5757
it("should not ignored", function () {
5858
const textlint = new TextLintCore();
5959
textlint.setupRules({
60-
ignore: ignoreRule,
60+
ignore: filterRule,
6161
report: reportRule
6262
}, {
6363
report: {
@@ -84,7 +84,7 @@ This is Error.
8484
it("should ignore messages of ruleA", function () {
8585
const textlint = new TextLintCore();
8686
textlint.setupRules({
87-
ignore: ignoreRule,
87+
ignore: filterRule,
8888
ruleA: reportRule
8989
}, {
9090
ruleA: {
@@ -104,7 +104,7 @@ This is text.
104104
it("should not ignore messages of other rules", function () {
105105
const textlint = new TextLintCore();
106106
textlint.setupRules({
107-
ignore: ignoreRule,
107+
ignore: filterRule,
108108
ruleX: reportRule
109109
}, {
110110
ruleX: {
@@ -126,7 +126,7 @@ This is text.
126126
it("should ignore messages of ruleA", function () {
127127
const textlint = new TextLintCore();
128128
textlint.setupRules({
129-
ignore: ignoreRule,
129+
ignore: filterRule,
130130
ruleA: reportRule,
131131
ruleB: reportRule
132132
}, {

0 commit comments

Comments
 (0)