Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
create-eslint-index
Advanced tools
Simplify the creation an index file for your ESLint plugin
$ npm install --save create-eslint-index req-all
With 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.
The new rule format looks like the following:
'use strict';
const create = (context) => {
// ...
};
module.exports = {
create,
meta: {
docs: {
recommended: 'error',
description: 'Description'
}
}
};
const createIndex = require('create-eslint-index');
const reqAll = require('req-all');
const rules = reqAll('rules', {camelize: false}); // Loads all rules from the `rules` folder and puts them in an object.
const recommendedRules = createIndex.createConfig({
plugin: '<name>', // Your plugin name, without the `eslint-plugin-` prefix
field: 'meta.docs.recommended'
}, rules);
module.exports = {
rules,
configs: {
recommended: {
rules: recommendedRules
}
}
};
$ npm install --save-dev inject-in-tag
package.json
:
{
"scripts": {
"update-md": "inject-in-tag ./rule-description.js README.md"
}
}
README.md
:
### Rules
<!-- RULES:START these comments are invisible to the reader -->
<!-- RULES:END -->
rule-description.js
:
const reqAll = require('req-all');
const createIndex = require('create-eslint-index');
const index = require('./');
const rules = reqAll('rules', {camelize: false});
const settings = {
descriptionField: 'meta.docs.description',
docPath: 'docs/rules'
};
module.exports = {
RULES: `\n${createIndex.createRulesDescription(settings, rules)}\n`
};
Result in the README:
### Rules
<!-- RULES:START these comments are invisible to the reader -->
- [rule-1](docs/rules/rule-1.md) - This is rule 1
- [rule-2](docs/rules/rule-2.md) - This is rule 2
<!-- RULES:END -->
Creates a recommended setting object
object
)string
): Name of your plugin, without the "eslint-plugin-" prefix. If your plugin name is "eslint-plugin-foo", this should then evaluate to "foo".string
): Path to get to the recommended value of a rule.object
)Object containing each rule, where the key is the name of the rule and the value is the exported content of the file rule.
See the example above for a more practical illustration.
const rules = [
'rule-1': {
create() {},
meta: {
docs: {
recommended: 'error',
description: 'This is rule 1'
}
}
},
'rule-2': {
create() {},
meta: {
docs: {
recommended: ['error', 'option'],
description: 'This is rule 2'
}
}
},
];
createIndex.createConfig({
plugin: 'foo',
path: 'meta.docs.recommended'
}, rules);
/* =>
{
'foo/rule-1': 'error',
'foo/rule-2': ['error', 'option']
}
*/
Creates a list of rules and their description, as one big string.
object
)string
): Relative path to the documentation folder containing Markdown files matching your rules.string
): Path to get to the description value of a rule.object
)Object containing each rule, where the key is the name of the rule and the value is the exported content of the file rule.
Let's assume rules
is declared as in the previous example.
const rules = reqAll('rules', {camelize: false});
const settings = {
descriptionField: 'meta.docs.description',
docPath: 'docs/rules'
};
console.log(createIndex.createRulesDescription(settings, rules));
/* =>
- [rule-1](docs/rules/rule-1.md) - This is rule 1
- [rule-2](docs/rules/rule-2.md) - This is rule 2
*/
MIT © Jeroen Engels
FAQs
Simplify the creation an index file for your ESLint plugin
The npm package create-eslint-index receives a total of 34,459 weekly downloads. As such, create-eslint-index popularity was classified as popular.
We found that create-eslint-index demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.