@zibuthe7j11/quo-facilis-commodi

1.0.0 • Public • Published

@zibuthe7j11/quo-facilis-commodi

A plugin for ESLint that allows you to use project-specific rules, similar to the deprecated --rulesdir command line option (more).

Install

npm install @zibuthe7j11/quo-facilis-commodi

Usage (JavaScript)

./eslint-local-rules.js (or ./eslint-local-rules/index.js)

'use strict';

module.exports = {
  'disallow-identifiers': {
    meta: {
      docs: {
        description: 'disallow identifiers',
        category: 'Possible Errors',
      },
      schema: [],
    },
    create: function (context) {
      return {
        Identifier: function (node) {
          context.report({
            node: node,
            message: 'Identifiers not allowed for Super Important reasons.',
          });
        },
      };
    },
  },
};

./.eslintrc

{
  "plugins": ["@zibuthe7j11/quo-facilis-commodi"],

  "rules": {
    "local-rules/disallow-identifiers": "error"
  }
}

Usage (TypeScript)

npm install ts-node @types/eslint

You'll also need an eslint config like the .eslintrc above (more info).

./eslint-local-rules/index.js

require("ts-node").register({
  transpileOnly: true,
  compilerOptions: {
    module: "commonjs",
  },
});

module.exports = require("./rules").default;

./eslint-local-rules/rules.ts

import type { Rule } from "eslint";

export default {
  "disallow-identifiers": {
    meta: {
      docs: {
        description: 'disallow identifiers',
        category: 'Possible Errors',
      },
      schema: [],
    },
    create: function (context) {
      return {
        Identifier: function (node) {
          context.report({
            node: node,
            message: 'Identifiers not allowed for Super Important reasons.',
          });
        },
      };
    },
  },
} satisfies Record<string, Rule.RuleModule>;

npm/yarn/pnpm workspaces support

This plugin supports npm/yarn/pnpm workspaces, although note that if the eslint-local-rules.js file is in the workspace subdirectory, running from the project root is unsupported.

For example, if there's an eslint-local-rules.js and index.js in ./src/app:

Wrong: npx eslint src/app/index.js

Right: (cd src/app; npx eslint index.js)

Also note that if there is an eslint-local-rules.js file in both the workspace subdirectory and project root, the workspace one takes precedence (assuming you're running eslint from the workspace directory, as above).

Alternatives

Context for this plugin

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.02latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.02

Package Sidebar

Install

npm i @zibuthe7j11/quo-facilis-commodi

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

17.2 kB

Total Files

10

Last publish

Collaborators

  • vnhat562