eslint-plugin-mycujoo
v1.0.0-rc.0
Published
Custom ESlint plugin
Downloads
1
Maintainers
Readme
@mycujoo/eslint-plugin
This ESLint plugin enforces MyCujoo custom eslint rules.
Usage
Assuming you already have ESLint installed, run:
# npm
npm install @mycujoo/eslint-plugin --save-dev
# yarn
yarn add @mycujoo/eslint-plugin --dev
Then extend the recommended eslint config:
{
"extends": [
// ...
"plugin:@mycujoo/eslint-plugin/recommended"
]
}
Custom Configuration
If you want more fine-grained configuration, you can instead add a snippet like this to your ESLint configuration file:
{
"plugins": [
// ...
"@mycujoo/eslint-plugin"
],
"rules": {
// ...
"@mycujoo/eslint-plugin/json-safety": "error",
}
}
Adding new rules
To add a new rule:
- create a new rule file inside the rules folder. The name should be suggestive of the rule.
- Basic rule content:
"use strict";
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Rule docs description",
url: "https://documentation.com",
},
messages: {
CUSTOM_RULE_MESSAGE_ID:
"Rule description",
},
},
create(context) {
return {
Identifier(node) {
// rule logic
context.report({
node,
message: "CUSTOM_RULE_MESSAGE_ID",
fix: (fixer) => {
// fixer logic
},
});
},
};
},
};
}
- Name and export the new rule in
/rules/index.js