Skip to content

Commit

Permalink
Added rule no-mixin.
Browse files Browse the repository at this point in the history
  • Loading branch information
bre1470 committed Apr 9, 2021
1 parent 73c3895 commit c4aa169
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions lib/rules/no-mixin.js
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

};
}
};

0 comments on commit c4aa169

Please sign in to comment.