nl_tokens: context object Constructor to set read - only properties and provide additional functionality to the rules using it
pl_tokens: function RuleContext ( ruleName , ruleDesc , ruleMeta , Solium ) { let contextObject = this ; // Set contect attribute 'options' iff options were provided. ruleDesc . options && Object . assign ( contextObject , { options : ruleDesc . options } ) ; //set read-only properties of the context object Object . defineProperties ( contextObject , { name : { <mask> : ruleName , writable : false //though the default is false anyway, I think its better to express your intention clearly } , meta : { value : ruleDesc , writable : false } } ) ; //inherit all Solium methods which are of relevance to the rule INHERITABLE_METHODS . forEach ( function ( methodName ) { contextObject [ methodName ] = function ( s , z , a , b , o ) { //every method will receive 5 arguments tops return Solium [ methodName ] . call ( Solium , s , z , a , b , o ) ; } ; } ) ; /**
       * wrapper around Solium.report () which adds some additional information to the error object
       * @param {Object} error An object describing the lint error, sent by the rule currently running
       */ contextObject . report = function ( error ) { if ( ! isErrObjectValid ( error ) ) { throw new Error ( ` ${ ruleName } ${ EOL } ${ util . inspect ( isErrObjectValid . errors ) } ` ) ; } Object . assign ( error , { ruleName : ruleName , ruleMeta : ruleMeta , type : contextObject . meta . type } ) ; Solium . report ( error ) ; } ; }