@nodelint/policy
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

policy

Nodelint policy

🚧 Requirements

  • Node.js LTS 16.x or higher
  • Top Level Await

💃 Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @nodelint/policy
# or
$ yarn add @nodelint/policy

👀 Usage example

Create your own policy, an example:

import url from "node:url";
import path from "node:path";
import { Policy, CONSTANTS } from "@nodelint/policy";

// Import an Array of Nodelint events
import * as events from "./events/index.js";

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

async function* main(ctx) {
    console.log(ctx); // <-- from core
    console.log("execute!");

    yield events.foo.id;
}

const i18n = await Policy.loadi18n(path.join(__dirname, "i18n"));

export default new Policy({
    name: "custom",
    mode: CONSTANTS.Mode.Asynchronous,
    defaultLang: "french",
    scope: [".eslintrc"],
    i18n,
    events,
    main
});

Then create create your own Event in a ./events folder

import { Event, CONSTANTS } from "@nodelint/policy";

const parameters = {
    type: "object",
    additionalProperties: false,
    properties: {
        burst: {
            type: "boolean",
            default: false
        }
    }
};

class foo extends Event {
    constructor() {
        super({
            name: "foo",
            type: CONSTANTS.Events.Error,
            i18n: "path.to.key",
            parameters
        });

        this.burst = false;
    }
}
export default new foo();

Contributors

All Contributors

Thanks goes to these wonderful people (emoji key):


Gentilhomme

💻 📖 🛡️ ⚠️

Vincent Dhennin

💻 📖

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @nodelint/policy

Weekly Downloads

4

Version

1.1.2

License

MIT

Unpacked Size

17 kB

Total Files

11

Last publish

Collaborators

  • fraxken