@jterrazz/codestyle 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ Create `.oxlintrc.json`:
12
12
 
13
13
  ```json
14
14
  {
15
- "extends": ["@jterrazz/codestyle/oxlint/node"]
15
+ "extends": ["node_modules/@jterrazz/codestyle/src/oxlint/node.json"]
16
16
  }
17
17
  ```
18
18
 
@@ -25,11 +25,12 @@ npx codestyle --fix # Fix everything
25
25
 
26
26
  ## Configurations
27
27
 
28
- | Config | Use Case |
29
- | ----------------------------------- | --------------------------------- |
30
- | `@jterrazz/codestyle/oxlint/node` | Node.js (requires .js extensions) |
31
- | `@jterrazz/codestyle/oxlint/expo` | Expo / React Native |
32
- | `@jterrazz/codestyle/oxlint/nextjs` | Next.js |
28
+ | Config | Use Case |
29
+ | -------------------------------------------------------------------------- | ---------------------------------- |
30
+ | `node_modules/@jterrazz/codestyle/src/oxlint/node.json` | Node.js (requires .js extensions) |
31
+ | `node_modules/@jterrazz/codestyle/src/oxlint/expo.json` | Expo / React Native |
32
+ | `node_modules/@jterrazz/codestyle/src/oxlint/nextjs.json` | Next.js |
33
+ | `node_modules/@jterrazz/codestyle/src/oxlint/architectures/hexagonal.json` | Hexagonal architecture enforcement |
33
34
 
34
35
  ## What's Included
35
36
 
@@ -38,6 +39,7 @@ npx codestyle --fix # Fix everything
38
39
  - Named exports enforcement (no default exports)
39
40
  - Performance warnings (spread in loops, etc.)
40
41
  - Style consistency (curly braces, comments, naming)
42
+ - Custom rules: architecture boundaries, import extensions
41
43
 
42
44
  ## CLI
43
45
 
@@ -57,8 +59,8 @@ Enforce hexagonal architecture boundaries:
57
59
  ```json
58
60
  {
59
61
  "extends": [
60
- "@jterrazz/codestyle/oxlint/node",
61
- "@jterrazz/codestyle/oxlint/architectures/hexagonal"
62
+ "node_modules/@jterrazz/codestyle/src/oxlint/node.json",
63
+ "node_modules/@jterrazz/codestyle/src/oxlint/architectures/hexagonal.json"
62
64
  ]
63
65
  }
64
66
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jterrazz/codestyle",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "author": "Jean-Baptiste Terrazzoni <contact@jterrazz.com>",
5
5
  "bin": {
6
6
  "codestyle": "./src/codestyle.sh"
@@ -27,8 +27,7 @@
27
27
  "lint:fix": "oxlint --fix --ignore-pattern '**/fixtures/**' && oxfmt",
28
28
  "test": "vitest --run",
29
29
  "test:watch": "vitest",
30
- "build": "# no build script",
31
- "postinstall": "node src/postinstall.js"
30
+ "build": "# no build script"
32
31
  },
33
32
  "dependencies": {
34
33
  "@typescript/native-preview": "^7.0.0-dev",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
3
3
  "plugins": ["typescript", "import", "oxc", "unicorn"],
4
- "jsPlugins": ["eslint-plugin-perfectionist", "./plugins/codestyle.js"],
4
+ "jsPlugins": ["eslint-plugin-perfectionist", "@jterrazz/codestyle/oxlint/plugins/codestyle"],
5
5
  "categories": {
6
6
  "correctness": "error",
7
7
  "suspicious": "error",
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from "fs";
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
-
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
-
9
- function findProjectRoot() {
10
- let dir = process.cwd();
11
- if (dir.includes("node_modules")) {
12
- dir = dir.split("node_modules")[0];
13
- }
14
- return dir;
15
- }
16
-
17
- // Rule mappings based on extended configs
18
- const ruleMappings = [
19
- {
20
- pattern: "architectures/hexagonal",
21
- rule: ["codestyle/arch-hexagonal", "error"],
22
- },
23
- {
24
- pattern: "oxlint/node",
25
- rule: ["codestyle/imports-with-ext", "error"],
26
- },
27
- {
28
- pattern: "oxlint/expo",
29
- rule: ["codestyle/imports-without-ext", "error"],
30
- },
31
- {
32
- pattern: "oxlint/nextjs",
33
- rule: ["codestyle/imports-without-ext", "error"],
34
- },
35
- ];
36
-
37
- function run() {
38
- const projectRoot = findProjectRoot();
39
- const configPath = path.join(projectRoot, ".oxlintrc.json");
40
-
41
- if (!fs.existsSync(configPath)) {
42
- return;
43
- }
44
-
45
- let config;
46
- try {
47
- config = JSON.parse(fs.readFileSync(configPath, "utf8"));
48
- } catch {
49
- console.log("[@jterrazz/codestyle] Could not parse .oxlintrc.json");
50
- return;
51
- }
52
-
53
- const configStr = JSON.stringify(config);
54
- const neededRules = new Map();
55
- let needsPlugin = false;
56
-
57
- for (const mapping of ruleMappings) {
58
- if (configStr.includes(mapping.pattern)) {
59
- neededRules.set(mapping.rule[0], mapping.rule[1]);
60
- needsPlugin = true;
61
- }
62
- }
63
-
64
- if (!needsPlugin) {
65
- return;
66
- }
67
-
68
- let updated = false;
69
- const updates = [];
70
-
71
- // Add plugin
72
- const pluginPath = "./node_modules/@jterrazz/codestyle/src/oxlint/plugins/codestyle.js";
73
- config.jsPlugins = config.jsPlugins || [];
74
- if (!config.jsPlugins.includes(pluginPath)) {
75
- config.jsPlugins.push(pluginPath);
76
- updated = true;
77
- updates.push(" + jsPlugins: codestyle.js");
78
- }
79
-
80
- // Add rules
81
- config.rules = config.rules || {};
82
- for (const [ruleName, ruleLevel] of neededRules) {
83
- if (!config.rules[ruleName]) {
84
- config.rules[ruleName] = ruleLevel;
85
- updated = true;
86
- updates.push(` + rule: ${ruleName}`);
87
- }
88
- }
89
-
90
- if (!updated) {
91
- return;
92
- }
93
-
94
- fs.writeFileSync(
95
- configPath,
96
- `${JSON.stringify(config, null, 2)}
97
- `,
98
- );
99
-
100
- console.log("[@jterrazz/codestyle] Updated .oxlintrc.json:");
101
- for (const update of updates) {
102
- console.log(update);
103
- }
104
- }
105
-
106
- run();