Nodelint policy
- Node.js LTS 16.x or higher
- Top Level Await
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
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();
Thanks goes to these wonderful people (emoji key):
Gentilhomme 💻 📖 🛡️ |
Vincent Dhennin 💻 📖 |
MIT