You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
747 B
JavaScript
36 lines
747 B
JavaScript
"use strict";
|
|
|
|
const __hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
|
// Checks that each rule is defined only once.
|
|
function reportDuplicateRules( ast, session ) {
|
|
|
|
const rules = {};
|
|
|
|
const check = session.buildVisitor( {
|
|
rule( node ) {
|
|
|
|
const name = node.name;
|
|
|
|
if ( __hasOwnProperty.call( rules, name ) ) {
|
|
|
|
const start = rules[ name ].start;
|
|
|
|
session.error(
|
|
`Rule "${ name }" is already defined at line ${ start.line }, column ${ start.column }.`,
|
|
node.location
|
|
);
|
|
|
|
}
|
|
|
|
rules[ node.name ] = node.location;
|
|
|
|
}
|
|
} );
|
|
|
|
check( ast );
|
|
|
|
}
|
|
|
|
module.exports = reportDuplicateRules;
|