Skip to content

Commit

Permalink
feat: add configs
Browse files Browse the repository at this point in the history
  • Loading branch information
stabback committed Oct 25, 2024
1 parent f6a019e commit 5b8eb36
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 857 deletions.
14 changes: 14 additions & 0 deletions lib/configs/browser-jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const globals = require("globals");
const commonRules = require("./common-rules");

module.exports = {
plugins: {
"6river": require("../plugin"),
},
rules: { ...commonRules },
languageOptions: {
globals: {
...globals.browser,
},
},
};
30 changes: 30 additions & 0 deletions lib/configs/common-rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
"max-len": ["warn", 120, 2],
curly: ["error", "all"],
"prefer-const": ["error"],
"no-console": ["error"],
"no-fallthrough": ["error"],
"no-undef": ["error"],
"no-var": ["error"],
strict: ["error", "global"],
"object-shorthand": "error",
"no-await-in-loop": "error",
eqeqeq: "error",
"require-jsdoc": "off",
"import/order": [
"error",
{
groups: [
["builtin"],
["external"],
["internal", "parent", "sibling", "index"],
],
"newlines-between": "always",
alphabetize: {
order: "asc",
},
},
],
"import/no-self-import": "error",
"import/newline-after-import": "error",
};
17 changes: 17 additions & 0 deletions lib/configs/node-mocha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const globals = require("globals");
const commonRules = require("./common-rules");
const mocha = require("eslint-plugin-mocha");

module.exports = {
plugins: {
mocha: mocha,
"6river": require("../plugin"),
},
rules: { ...commonRules, "mocha/no-exclusive-tests": "error" },
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
},
},
};
24 changes: 7 additions & 17 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
/**
* @fileoverview set of 6river eslint plugins
* @author Nick Chistyakov
*/
"use strict";
const plugin = require("./plugin");

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
// https://eslint.org/docs/latest/extend/plugins#configs-in-plugins
Object.assign(plugin.configs, {
"browser-jest": require("./configs/browser-jest"),
"node-mocha": require("./configs/node-mocha"),
});

var requireIndex = require("requireindex");

//------------------------------------------------------------------------------
// Plugin Definition
//------------------------------------------------------------------------------


// import all rules in lib/rules
module.exports.rules = requireIndex(__dirname + "/rules");
module.exports = plugin;
31 changes: 31 additions & 0 deletions lib/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @fileoverview set of 6river eslint plugins
* @author Nick Chistyakov
*/
"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

const requireIndex = require("requireindex");
const fs = require("node:fs");
const { browser } = require("globals");
const nodeMocha = require("./configs/node-mocha");
const pkg = JSON.parse(
fs.readFileSync(new URL("./package.json", import.meta.url), "utf8"),
);

//------------------------------------------------------------------------------
// Plugin Definition
//------------------------------------------------------------------------------

const plugin = {
rules: requireIndex(__dirname + "/rules"),
meta: {
name: pkg.name,
version: pkg.version,
},
};

module.exports = plugin;
Loading

0 comments on commit 5b8eb36

Please sign in to comment.