Skip to content

Commit 34d4d00

Browse files
committed
fix(rule): fix edge case of difference line number
fix #1
1 parent 4a3e612 commit 34d4d00

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"test": "test"
2323
},
2424
"scripts": {
25-
"build": "babel src --out-dir lib --source-maps",
25+
"build": "NODE_ENV=production babel src --out-dir lib --source-maps",
2626
"watch": "babel src --out-dir lib --watch --source-maps",
2727
"prepublish": "npm run --if-present build",
2828
"test": "mocha"

src/sentence-length.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function (context, options = {}) {
3131
if (sentenceText.length > maxLength) {
3232
let currentLine = node.loc.start.line;
3333
const addedLine = isStartWithNewLine(sentenceText)
34-
? sentence.loc.start.line // \n string
34+
? sentence.loc.start.line + 1// \n string
3535
: sentence.loc.start.line - 1; // string
3636
let paddingLine = Math.max(addedLine, 0);
3737
let paddingIndex = sentence.range[0];

test/sentence-length-test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ line4
8080
},
8181
// example
8282
{
83-
text: `_Middleware_ という仕組み自体は[Connect](../connect/README.md)と似ています。
83+
text: `This is text.
84+
85+
_Middleware_ という仕組み自体は[Connect](../connect/README.md)と似ています。
8486
しかし、 _Middleware_ が直接的に結果(State)を直接書き換える事はできません。
8587
これは、Connectが最終的な結果(response)を書き換えできるの対して、
8688
Reduxの _Middleware_ は扱える範囲がdispatchからReducerまでと線引されている違いと言えます。`,
@@ -89,7 +91,7 @@ Reduxの _Middleware_ は扱える範囲がdispatchからReducerまでと線引
8991
},
9092
errors: [
9193
{
92-
message: `Line 3 exceeds the maximum line length of 100.`
94+
message: `Line 5 exceeds the maximum line length of 100.`
9395
}
9496
]
9597
}

0 commit comments

Comments
 (0)