diff --git a/src/rules/examples/async.js b/src/rules/examples/async.js deleted file mode 100644 index d4223d3..0000000 --- a/src/rules/examples/async.js +++ /dev/null @@ -1,40 +0,0 @@ -import logging from '../../lib/logger.js'; - -const logger = logging('rule:async'); - -/** - * @typedef AsyncConfig - * @property {"error"|"warn"|"log"|null} method The method to call on reporter - * @property {String} message The message to warn/error with - * @property {Number} wait The number of seconds to wait - */ - -const asyncExample = { - /** - * Generates a linting function from a config - * @param {AsyncConfig} config - */ - generate(config) { - return function (reporter) { - logger.debug('Called', config); - let {wait} = config; - return new Promise((resolve) => { - const intervalID = setInterval(() => { - if (--wait <= 0) { - clearInterval(intervalID); - // Report the message if type !== succeed - if (config.method) { - reporter[config.method](config.message); - } - - resolve(); - } else { - logger.log(wait, 'seconds to go'); - } - }, 1000); - }); - }; - }, -}; - -export default asyncExample; diff --git a/src/rules/examples/elms.js b/src/rules/examples/elms.js deleted file mode 100644 index 6555692..0000000 --- a/src/rules/examples/elms.js +++ /dev/null @@ -1,34 +0,0 @@ -import logging from '../../lib/logger.js'; - -const logger = logging('rule:elms'); - -/** - * @typedef ElmsConfig - * @property {"error"|"warn"} method The method to call on reporter - * @property {String} message The message to warn/error with - * @property {String} selector Selector to find the element we want to warn/error with. - * The first of all matching elements will be used. - */ - -const elmsExample = { - /** - * Generates a linting function from a config - * @param {ElmsConfig} config - */ - generate(config) { - /** - * Performs the linting according to the previously passed config. - * @param {Reporter} reporter The reporter to report warnings/errors to - * @param {Cheerio} $ A cheerio representation of the document - * @param {AST} ast The underlying AST representation of the document. - * This should be given to Reporter when warning/erroring with a node. - */ - return function (reporter, $, ast) { - logger.debug('Called', config); - const elm = $(config.selector)[0]; - reporter[config.method](config.message, elm, ast); - }; - }, -}; - -export default elmsExample; diff --git a/src/rules/examples/identity.js b/src/rules/examples/identity.js deleted file mode 100644 index 74cf6c0..0000000 --- a/src/rules/examples/identity.js +++ /dev/null @@ -1,27 +0,0 @@ -import logging from '../../lib/logger.js'; - -const logger = logging('rule:identity'); - -/** - * @typedef IdentityConfig - * @property {"error"|"warn"|null} method The method to call on reporter - * @property {String} message The message to warn/error with - */ - -const identityExample = { - /** - * Generates a linting function from a config - * @param {IdentityConfig} config - */ - generate(config) { - return function (reporter) { - logger.debug('Called', config); - // Report the message if type !== succeed - if (config.method) { - reporter[config.method](config.message); - } - }; - }, -}; - -export default identityExample; diff --git a/src/rules/examples/throws.js b/src/rules/examples/throws.js deleted file mode 100644 index b438b53..0000000 --- a/src/rules/examples/throws.js +++ /dev/null @@ -1,24 +0,0 @@ -import logging from '../../lib/logger.js'; - -const logger = logging('rule:throws'); - -/** - * @typedef ThrowsConfig - * @property {String} message The message to throw - */ - -const throwsExample = { - /** - * Generates a linting function from a config - * @param {ThrowsConfig} config - */ - generate(config) { - return function (reporter) { - logger.debug('Called', config); - reporter.warn('This will throw now'); - throw new Error(config.message); - }; - }, -}; - -export default throwsExample;