-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* @fileoverview Create and use events instead of mixins modifications. | ||
*/ | ||
'use strict'; | ||
|
||
const message = 'Do not use mixins.'; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Rule Definition | ||
//------------------------------------------------------------------------------ | ||
|
||
module.exports = { | ||
meta: { | ||
docs: { | ||
description: message, | ||
category: 'Migration', | ||
recommended: false | ||
}, | ||
fixable: null, // or "code" or "whitespace" | ||
schema: [ | ||
// fill in your schema | ||
] | ||
}, | ||
|
||
create: function (context) { | ||
|
||
// variables should be defined here | ||
const code = context.getSourceCode().lines.join('\n'); | ||
|
||
//---------------------------------------------------------------------- | ||
// Helpers | ||
//---------------------------------------------------------------------- | ||
const program = (node) => { | ||
|
||
const regex = /(?:import|from)\s+\'[^']*\/(Mixins\/)/g; | ||
|
||
let match; | ||
|
||
while (match = regex.exec(code)) { | ||
const codeBefore = code.substr(0, regex.lastIndex - match[1].length); | ||
const linesBefore = codeBefore.split('\n'); | ||
const line = linesBefore[linesBefore.length - 1]; | ||
|
||
context.report({ | ||
node: node, | ||
loc: { | ||
line: linesBefore.length, | ||
column: line.length | ||
}, | ||
message: message | ||
}); | ||
} | ||
}; | ||
|
||
//---------------------------------------------------------------------- | ||
// Public | ||
//---------------------------------------------------------------------- | ||
return { | ||
|
||
Program: program | ||
|
||
}; | ||
} | ||
}; |