{"_id":"create-eslint-index","_rev":"303792","name":"create-eslint-index","description":"Simplify the creation an index file for your ESLint plugin","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"jfmengels","email":""}],"time":{"modified":"2021-06-03T19:24:36.000Z","created":"2016-07-14T15:11:49.422Z","1.0.0":"2016-07-14T15:11:49.422Z"},"users":{},"author":{"name":"Jeroen Engels","email":"jfm.engels@gmail.com","url":"github.com/jfmengels"},"repository":{"type":"git","url":"git+https://github.com/jfmengels/create-eslint-index.git"},"versions":{"1.0.0":{"name":"create-eslint-index","version":"1.0.0","description":"Simplify the creation an index file for your ESLint plugin","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jfmengels/create-eslint-index.git"},"author":{"name":"Jeroen Engels","email":"jfm.engels@gmail.com","url":"github.com/jfmengels"},"engines":{"node":">=4.0.0"},"scripts":{"test":"xo && nyc ava"},"files":["index.js"],"keywords":["eslint","eslintplugin","helper","index"],"dependencies":{"lodash.get":"^4.3.0"},"devDependencies":{"ava":"^0.15.1","coveralls":"^2.11.9","nyc":"^6.4.0","req-all":"^0.1.0","xo":"^0.15.0"},"nyc":{"reporter":["lcov","text"]},"xo":{"esnext":true,"space":2},"gitHead":"1ddd6fe3d8666ce97f368ec6a81fe83362573b8e","bugs":{"url":"https://github.com/jfmengels/create-eslint-index/issues"},"homepage":"https://github.com/jfmengels/create-eslint-index#readme","_id":"create-eslint-index@1.0.0","_shasum":"d954372d86d5792fcd67e9f2b791b1ab162411bb","_from":".","_npmVersion":"3.8.6","_nodeVersion":"5.12.0","_npmUser":{"name":"jfmengels","email":"jfm.engels@gmail.com"},"dist":{"shasum":"d954372d86d5792fcd67e9f2b791b1ab162411bb","size":2928,"noattachment":false,"key":"/create-eslint-index/-/create-eslint-index-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/create-eslint-index/download/create-eslint-index-1.0.0.tgz"},"maintainers":[{"name":"jfmengels","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/create-eslint-index-1.0.0.tgz_1468509107177_0.34724317234940827"},"directories":{},"publish_time":1468509109422,"_cnpm_publish_time":1468509109422,"_hasShrinkwrap":false}},"readme":"# create-eslint-index [![Build Status](https://travis-ci.org/jfmengels/create-eslint-index.svg?branch=master)](https://travis-ci.org/jfmengels/create-eslint-index) [![Coverage Status](https://coveralls.io/repos/github/jfmengels/create-eslint-index/badge.svg?branch=master)](https://coveralls.io/github/jfmengels/create-eslint-index?branch=master)\n\n> Simplify the creation an index file for your ESLint plugin\n\n\n## Install\n\n```\n$ npm install --save create-eslint-index req-all\n```\n\nWith ESLint 3, a new rule format has been introduced. This new format makes it easier to attach metadata to each rule, which can then be used to generate recommended configurations and/or rule lists in the README automatically.\n\nThe new rule format looks like the following:\n\n```js\n'use strict';\n\nconst create = (context) => {\n  // ...\n};\n\nmodule.exports = {\n  create,\n  meta: {\n    docs: {\n      recommended: 'error',\n      description: 'Description'\n    }\n  }\n};\n```\n\n## Usage\n\n### Creating a recommended configuration automatically\n\n```js\nconst createIndex = require('create-eslint-index');\nconst reqAll = require('req-all');\n\nconst rules = reqAll('rules', {camelize: false}); // Loads all rules from the `rules` folder and puts them in an object.\n\nconst recommendedRules = createIndex.createConfig({\n  plugin: '<name>', // Your plugin name, without the `eslint-plugin-` prefix\n  field: 'meta.docs.recommended'\n}, rules);\n\nmodule.exports = {\n  rules,\n  configs: {\n    recommended: {\n      rules: recommendedRules\n    }\n  }\n};\n```\n\n### Creating a script that injects a summary of the rules in the README\n\n```\n$ npm install --save-dev inject-in-tag\n```\n\n`package.json`:\n```json\n{\n  \"scripts\": {\n    \"update-md\": \"inject-in-tag ./rule-description.js README.md\"\n  }\n}\n```\n\n`README.md`:\n```md\n### Rules\n\n<!-- RULES:START these comments are invisible to the reader -->\n<!-- RULES:END -->\n```\n\n`rule-description.js`:\n```js\nconst reqAll = require('req-all');\nconst createIndex = require('create-eslint-index');\nconst index = require('./');\n\nconst rules = reqAll('rules', {camelize: false});\n\nconst settings = {\n  descriptionField: 'meta.docs.description',\n  docPath: 'docs/rules'\n};\n\nmodule.exports = {\n  RULES: `\\n${createIndex.createRulesDescription(settings, rules)}\\n`\n};\n```\n\nResult in the README:\n```md\n### Rules\n\n<!-- RULES:START these comments are invisible to the reader -->\n- [rule-1](docs/rules/rule-1.md) - This is rule 1\n- [rule-2](docs/rules/rule-2.md) - This is rule 2\n<!-- RULES:END -->\n```\n\n## API\n\n### createIndex.createConfig(settings, rules)\n\nCreates a recommended setting object\n\n#### settings (`object`)\n- settings.plugin (`string`): Name of your plugin, without the \"eslint-plugin-\" prefix. If your plugin name is \"eslint-plugin-foo\", this should then evaluate to \"foo\".\n- settings.path (`string`): Path to get to the recommended value of a rule.\n\n\n#### rules (`object`)\n\nObject containing each rule, where the key is the name of the rule and the value is the exported content of the file rule.\n\n#### Example\n\nSee the example above for a more practical illustration.\n\n```js\nconst rules = [\n  'rule-1': {\n    create() {},\n    meta: {\n      docs: {\n        recommended: 'error',\n        description: 'This is rule 1'\n      }\n    }\n  },\n  'rule-2': {\n    create() {},\n    meta: {\n      docs: {\n        recommended: ['error', 'option'],\n        description: 'This is rule 2'\n      }\n    }\n  },\n];\n\ncreateIndex.createConfig({\n  plugin: 'foo',\n  path: 'meta.docs.recommended'\n}, rules);\n/* =>\n{\n  'foo/rule-1': 'error',\n  'foo/rule-2': ['error', 'option']\n}\n*/\n```\n\n### createIndex.createRulesDescription(settings, rules)\n\nCreates a list of rules and their description, as one big string.\n\n#### settings (`object`)\n- settings.docPath (`string`): Relative path to the documentation folder containing Markdown files matching your rules.\n- settings.descriptionField (`string`): Path to get to the description value of a rule.\n\n#### rules (`object`)\n\nObject containing each rule, where the key is the name of the rule and the value is the exported content of the file rule.\n\n#### Example\n\nLet's assume `rules` is declared as in the previous example.\n\n```js\nconst rules = reqAll('rules', {camelize: false});\n\nconst settings = {\n  descriptionField: 'meta.docs.description',\n  docPath: 'docs/rules'\n};\n\nconsole.log(createIndex.createRulesDescription(settings, rules));\n/* =>\n- [rule-1](docs/rules/rule-1.md) - This is rule 1\n- [rule-2](docs/rules/rule-2.md) - This is rule 2\n*/\n```\n\n\n## License\n\nMIT © [Jeroen Engels](https://github.com/jfmengels)\n","_attachments":{},"homepage":"https://github.com/jfmengels/create-eslint-index#readme","bugs":{"url":"https://github.com/jfmengels/create-eslint-index/issues"},"license":"MIT"}