Skip to content

Commit

Permalink
refactor(js): migrate eol-last to ts (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
auvred authored Nov 14, 2023
1 parent 06048c3 commit 8272076
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
* @author Nodeca Team <https://github.com/nodeca>
*/

import { createRule } from '../../utils/createRule'

// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------

/** @type {import('eslint').Rule.RuleModule} */
export default {
export default createRule({
meta: {
type: 'layout',

Expand All @@ -21,6 +22,7 @@ export default {

schema: [
{
type: 'string',
enum: ['always', 'never', 'unix', 'windows'],
},
],
Expand Down Expand Up @@ -91,7 +93,7 @@ export default {
messageId: 'unexpected',
fix(fixer) {
const finalEOLs = /(?:\r?\n)+$/u
const match = finalEOLs.exec(sourceCode.text)
const match = finalEOLs.exec(sourceCode.text)! // endsWithNewline is true
const start = match.index
const end = sourceCode.text.length

Expand All @@ -102,4 +104,4 @@ export default {
},
}
},
}
})

0 comments on commit 8272076

Please sign in to comment.