1.1.2 • Published 1 year ago

@nodelint/policy v1.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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):

License

MIT

1.1.2

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago