eslint-plugin-local-rules
eslint-plugin-local-rules copied to clipboard
Add `all` config to automatically load all rules at `error` level
I tried this, but none of them work
module.exports = {
root: true,
env: {
node: true
},
plugins: ['eslint-plugin-local-rules'],
extends: [
'eslint:recommended',
'plugin:vue/essential',
'plugin:eslint-plugin-local-rules', // nope
'plugin:eslint-plugin-local-rules:recommended', // nope
'plugin:eslint-plugin-local-rules/recommended', // nope
],
...
rule example
module.exports = {
meta: {
docs: {
description: 'disallow identifiers',
category: 'Possible Errors',
recommended: true,
},
schema: [],
},
create: function (context) {
return {
Identifier: function (node) {
context.report({
node: node,
message: 'Identifiers not allowed for Super Important reasons.',
});
},
};
},
};
Looks like the automatic inclusion of recommended: true
rules only applies to core rules: https://eslint.org/docs/latest/extend/custom-rules#rule-structure:~:text=The%20following%20properties%20are%20only%20relevant%20when%20working%20on%20core%20rules
I'll remove that line from the README snippet, but to accomplish this you'd need to do what other non-core plugins have to do (example) and define your own "recommended" config following https://eslint.org/docs/latest/extend/plugins#configs-in-plugins .
This plugin currently doesn't allow that, but I believe https://github.com/taskworld/eslint-plugin-local can do what you need. I'll close this issue, but feel free to +1 #11 and we can maybe revive that.
As an aside, you may have it in a separate file, but just in case, make sure your actual eslint-local-rules.js file includes the rule identifiers as keys:
module.exports = {
'disallow-identifiers': {
meta: {
instead of just
module.exports = {
meta: {
I think the point of this request is to include a recommended.js
file in this package so that it automatically picks up any available rules and enables them. Essentially "configs in plugins", but as part of eslint-plugin-local-rules
(which is the plugin here)
The file technically should be all.js
rather than recommended.js
, because recommended
implies that some rules are not enabled by the config.
https://github.com/cletusw/eslint-plugin-local-rules/pull/11 is something different and unnecessary here. eslint-plugin-local-rules
is useful to load local rules, not move the location of the config; that config should just be added to .eslintrc
Great suggestion! Reopening & renaming to be a request for a bundled all
config.
I'll send a tentative PR
Excellent, thanks!