| 218 | } |
| 219 | |
| 220 | function splitLines(text) { |
| 221 | const lines = []; |
| 222 | |
| 223 | lines.lineFromIndex = function(index) { |
| 224 | const lines = this; |
| 225 | const lineCount = lines.length; |
| 226 | for (let i = 0; i < lineCount; i++) { |
| 227 | if (index < lines[i].index) return i - 1; |
| 228 | } |
| 229 | return lineCount - 1; |
| 230 | }; |
| 231 | |
| 232 | let m; |
| 233 | const reSplit = /(( *\* ?)?.*)(?:\r\n|\r|\n)/g; |
| 234 | while ((m = reSplit.exec(text)) != null) { |
| 235 | if (m.index === reSplit.lastIndex) { |
| 236 | reSplit.lastIndex++; |
| 237 | } |
| 238 | |
| 239 | lines.push({ |
| 240 | index: m.index, |
| 241 | text: m[1], |
| 242 | prefixLength: m[2] ? m[2].length : 0 |
| 243 | }); |
| 244 | } |
| 245 | |
| 246 | return lines; |
| 247 | } |
| 248 | |
| 249 | eslintFiles(null, process.argv.slice(2)) |
| 250 | .then(result => { |