UNPKG

eslint-plugin-unicorn

Version:
37 lines (32 loc) 911 B
import getDocumentationUrl from '../utils/get-documentation-url.js'; import toEslintCreate from './to-eslint-create.js'; /** @import * as ESLint from 'eslint'; @import {UnicornCreate} from './to-eslint-create.js'; */ /** @typedef {ESLint.Rule.RuleModule & { create: UnicornCreate }} UnicornRule */ /** Convert Unicorn rule to ESLint rule @param {string} ruleId @param {UnicornRule} unicornRule @returns {ESLint.Rule.RuleModule} */ export default function toEslintRule(ruleId, unicornRule) { return { meta: { // If there is are, options add `[]` so ESLint can validate that no data is passed to the rule. // https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-schema.md schema: [], ...unicornRule.meta, docs: { ...unicornRule.meta.docs, url: getDocumentationUrl(ruleId), }, }, create: toEslintCreate(unicornRule.create), }; }