Skip to content

Commit

Permalink
fix: πŸ› have better support for "prefer-node-protocol"
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-guzman committed Nov 1, 2024
1 parent a6d9bff commit cc27e4f
Show file tree
Hide file tree
Showing 13 changed files with 3,172 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jest-dom": "^5.4.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-node-import": "^1.0.4",
"eslint-plugin-n": "^17.12.0",
"eslint-plugin-perfectionist": "^3.9.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
Expand Down
37 changes: 29 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/configs/imports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ESLint, Linter } from "eslint";

import importX from "eslint-plugin-import-x";
import nodeImport from "eslint-plugin-node-import";
import nodePlugin from "eslint-plugin-n";

import type { TypescriptOptions } from "../types";

Expand Down Expand Up @@ -36,7 +36,7 @@ const importsConfig = ({ typescript = false }: ImportsConfigOptions = {}) => {
plugins: {
// TODO: remove unknown conversion
"import-x": importX as unknown as ESLint.Plugin,
"node-import": nodeImport,
"n": nodePlugin,
},
rules: importsRules,
// https://github.com/import-js/eslint-plugin-import/issues/2556#issuecomment-1419518561
Expand Down
19 changes: 19 additions & 0 deletions src/configs/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Linter } from "eslint";

import nodePlugin from "eslint-plugin-n";

import { nodeRules } from "../rules/node";

const nodeConfig = () => {
return [
{
name: "jimmy.codes/node",
plugins: {
n: nodePlugin,
},
rules: nodeRules,
},
] satisfies Linter.Config[];
};

export default nodeConfig;
25 changes: 25 additions & 0 deletions src/factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ import { jimmyDotCodes } from "./factory";
vi.mock("local-pkg");

describe("jimmyDotCodes", () => {
describe("base", () => {
it("should create configuration w/ node", () => {
expect(jimmyDotCodes({ autoDetect: false })).toStrictEqual(
expect.arrayContaining([
expect.objectContaining({ name: "jimmy.codes/node" }),
]),
);
});
it("should create configuration w/ imports", () => {
expect(jimmyDotCodes({ autoDetect: false })).toStrictEqual(
expect.arrayContaining([
expect.objectContaining({ name: "jimmy.codes/imports" }),
]),
);
});
it("should create configuration w/ perfectionist", () => {
expect(
jimmyDotCodes({ autoDetect: false, typescript: true }),
).toStrictEqual(
expect.arrayContaining([
expect.objectContaining({ name: "jimmy.codes/perfectionist" }),
]),
);
});
});
it("should create configuration w/ typescript", () => {
expect(
jimmyDotCodes({ autoDetect: false, typescript: true }),
Expand Down
2 changes: 2 additions & 0 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Options, TypedConfigItem } from "./types";
import { astroConfig } from "./configs/astro";
import { commonjsConfig } from "./configs/commonjs";
import importsConfig from "./configs/imports";
import nodeConfig from "./configs/node";
import perfectionistConfig from "./configs/perfectionist";
import reactConfig from "./configs/react";
import testingConfig from "./configs/testing";
Expand Down Expand Up @@ -40,6 +41,7 @@ export const jimmyDotCodes = (
return [
{ name: "jimmy.codes/base", rules: baseRules },
...perfectionistConfig(),
...nodeConfig(),
...importsConfig({ typescript: isTypescriptEnabled }),
...(isTypescriptEnabled
? typescriptConfig(getTypescriptOptions(typescript))
Expand Down
Loading

0 comments on commit cc27e4f

Please sign in to comment.