@schoero/configs 1.4.2 → 1.5.0

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/eslint/jsx.js CHANGED
@@ -2,16 +2,21 @@ import eslintPluginStylistic from "@stylistic/eslint-plugin";
2
2
  import eslintPluginTypeScript from "@typescript-eslint/eslint-plugin";
3
3
  import eslintParserTypeScript from "@typescript-eslint/parser";
4
4
 
5
+ import { eslintPluginJsx } from "./plugins/jsx/index.js";
6
+
5
7
 
6
8
  /** @type {import("eslint").Linter.Config[]} */
7
9
  export const jsx = [
8
10
  {
9
11
  files: ["**/*.{jsx,tsx}"],
10
12
  plugins: {
11
- "eslint-plugin-stylistic": eslintPluginStylistic
13
+ "eslint-plugin-stylistic": eslintPluginStylistic,
14
+ "eslint-plugin-jsx": eslintPluginJsx
12
15
  },
13
16
  rules: {
14
- "eslint-plugin-stylistic/no-extra-parens": "off"
17
+ "eslint-plugin-stylistic/no-extra-parens": "off",
18
+ "eslint-plugin-jsx/jsx-wrap-text": ["warn", { printWidth: 119 }],
19
+ "eslint-plugin-jsx/jsx-no-literals": "warn"
15
20
  }
16
21
  },
17
22
  {
@@ -0,0 +1,13 @@
1
+ import { jsxNoLiterals } from "./no-literals.js";
2
+ import { jsxWrapText } from "./wrap-text.js";
3
+
4
+
5
+ export const eslintPluginJsx = {
6
+ meta: {
7
+ name: "jsx"
8
+ },
9
+ rules: {
10
+ [jsxWrapText.name]: jsxWrapText.rule,
11
+ [jsxNoLiterals.name]: jsxNoLiterals.rule
12
+ }
13
+ };
@@ -0,0 +1,31 @@
1
+ export const jsxNoLiterals = {
2
+ rule: {
3
+ type: "layout",
4
+ create: context => {
5
+ return {
6
+ JSXText: node => {
7
+ const trimmed = node.value.replace(/\s+/g, " ").trim();
8
+ if(trimmed.length > 0){
9
+ context.report({
10
+ node,
11
+ messageId: "literalText",
12
+ data: { text: trimmed }
13
+ });
14
+ }
15
+
16
+ }
17
+ };
18
+ },
19
+ meta: {
20
+ type: "problem",
21
+ docs: {
22
+ description: "Disallow literal text in JSX to enforce translation/i18n."
23
+ },
24
+ messages: {
25
+ literalText: "Literal text '{{text}}' found in JSX. Use a translation instead."
26
+ },
27
+ schema: []
28
+ }
29
+ },
30
+ name: "jsx-no-literals"
31
+ };
@@ -0,0 +1,93 @@
1
+ export const jsxWrapText = {
2
+ rule: {
3
+ type: "layout",
4
+ create: context => {
5
+ const { printWidth = 80, indentation = 2 } = context.options[0] || {};
6
+
7
+ return {
8
+ JSXElement: node => {
9
+ for(const child of node.children){
10
+ if(child.type !== "JSXText"){
11
+ continue;
12
+ }
13
+
14
+ const raw = child.value;
15
+ const startPosition = node.loc.start.column;
16
+ const wrapped = wrapText(raw, printWidth, startPosition, indentation);
17
+
18
+ if(wrapped !== raw){
19
+ context.report({
20
+ node: child,
21
+ message: "JSX text exceeds print width of {{width}} characters.",
22
+ data: { width: printWidth },
23
+ fix(fixer) {
24
+ return fixer.replaceText(child, wrapped);
25
+ }
26
+ });
27
+ }
28
+ }
29
+ }
30
+ };
31
+ },
32
+ meta: {
33
+ docs: {
34
+ description: "Wrap long lines of plain text in JSX according to print width"
35
+ },
36
+ fixable: "whitespace",
37
+ schema: [
38
+ {
39
+ type: "object",
40
+ properties: {
41
+ printWidth: {
42
+ type: "number",
43
+ default: 80
44
+ },
45
+ indentation: {
46
+ type: "number",
47
+ default: 2
48
+ }
49
+ },
50
+ additionalProperties: false
51
+ }
52
+ ]
53
+ }
54
+ },
55
+ name: "jsx-wrap-text"
56
+ };
57
+
58
+
59
+ function wrapText(text, width, start, indentation) {
60
+ const whitespaceOnly = /^\s*$/;
61
+
62
+ if(whitespaceOnly.test(text)){
63
+ return text;
64
+ }
65
+
66
+ const words = text.trim().split(/\s+/);
67
+ const lines = [];
68
+ let currentLine = "";
69
+
70
+ for(const word of words){
71
+ const nextLine = currentLine ? `${currentLine} ${word}` : word;
72
+ if(start + indentation + nextLine.length > width){
73
+ if(currentLine){lines.push(currentLine);}
74
+ currentLine = word;
75
+ } else {
76
+ currentLine = nextLine;
77
+ }
78
+ }
79
+
80
+ if(currentLine){
81
+ lines.push(currentLine);
82
+ }
83
+
84
+ if(lines.length <= 1){
85
+ return text;
86
+ }
87
+
88
+ return [
89
+ "",
90
+ ...lines.map(line => " ".repeat(start + indentation) + line),
91
+ " ".repeat(start)
92
+ ].join("\n");
93
+ }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.2",
2
+ "version": "1.5.0",
3
3
  "type": "module",
4
4
  "name": "@schoero/configs",
5
5
  "description": "",
@@ -39,14 +39,14 @@
39
39
  "unwritten"
40
40
  ],
41
41
  "peerDependencies": {
42
- "@stylistic/eslint-plugin": "^4.4.0",
42
+ "@stylistic/eslint-plugin": "^4.4.1",
43
43
  "changelogen": "^0.6.1",
44
- "cspell": "^9.0.2",
45
- "eslint": "^9.27.0",
44
+ "cspell": "^9.1.1",
45
+ "eslint": "^9.29.0",
46
46
  "markdownlint": "^0.38.0",
47
47
  "unwritten": "^0.2.14",
48
48
  "vite": "^6.3.5",
49
- "vitest": "^3.1.4"
49
+ "vitest": "^3.2.3"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "@stylistic/eslint-plugin": {
@@ -79,29 +79,29 @@
79
79
  "@cspell/dict-companies": "^3.2.1",
80
80
  "@cspell/dict-css": "^4.0.17",
81
81
  "@cspell/dict-de-ch": "^1.3.0",
82
- "@cspell/dict-en_us": "^4.4.9",
82
+ "@cspell/dict-en_us": "^4.4.11",
83
83
  "@cspell/dict-fr-fr": "^2.3.0",
84
84
  "@cspell/dict-fullstack": "^3.2.6",
85
85
  "@cspell/dict-html": "^4.0.11",
86
86
  "@cspell/dict-html-symbol-entities": "^4.0.3",
87
87
  "@cspell/dict-it-it": "^3.1.4",
88
88
  "@cspell/dict-lorem-ipsum": "^4.0.4",
89
- "@cspell/dict-markdown": "^2.0.10",
89
+ "@cspell/dict-markdown": "^2.0.11",
90
90
  "@cspell/dict-node": "^5.0.7",
91
- "@cspell/dict-npm": "^5.2.4",
91
+ "@cspell/dict-npm": "^5.2.6",
92
92
  "@cspell/dict-public-licenses": "^2.0.13",
93
- "@cspell/dict-software-terms": "^5.0.10",
94
- "@cspell/dict-typescript": "^3.2.1",
95
- "@stylistic/eslint-plugin": "^4.4.0",
96
- "@typescript-eslint/eslint-plugin": "^8.33.0",
97
- "@typescript-eslint/parser": "^8.33.0",
98
- "cspell-lib": "^9.0.2",
93
+ "@cspell/dict-software-terms": "^5.1.0",
94
+ "@cspell/dict-typescript": "^3.2.2",
95
+ "@stylistic/eslint-plugin": "^4.4.1",
96
+ "@typescript-eslint/eslint-plugin": "^8.34.0",
97
+ "@typescript-eslint/parser": "^8.34.0",
98
+ "cspell-lib": "^9.1.1",
99
99
  "eslint-plugin-import-newlines": "^1.4.0",
100
- "eslint-plugin-import-x": "^4.13.3",
101
- "eslint-plugin-jsdoc": "^50.6.17",
100
+ "eslint-plugin-import-x": "^4.15.2",
101
+ "eslint-plugin-jsdoc": "^51.0.1",
102
102
  "eslint-plugin-jsonc": "^2.20.1",
103
103
  "eslint-plugin-markdown": "^5.1.0",
104
- "eslint-plugin-perfectionist": "^4.13.0",
104
+ "eslint-plugin-perfectionist": "^4.14.0",
105
105
  "eslint-plugin-unicorn": "^59.0.1",
106
106
  "eslint-plugin-unused-imports": "^4.1.4",
107
107
  "eslint-plugin-vitest": "^0.5.4",
@@ -112,16 +112,16 @@
112
112
  "yaml-eslint-parser": "^1.3.0"
113
113
  },
114
114
  "optionalDependencies": {
115
- "eslint-plugin-better-tailwindcss": "^3.0.0"
115
+ "eslint-plugin-better-tailwindcss": "^3.1.0"
116
116
  },
117
117
  "devDependencies": {
118
- "@types/node": "^22.15.23",
118
+ "@types/node": "^24.0.1",
119
119
  "changelogen": "^0.6.1",
120
- "cspell": "^9.0.2",
121
- "eslint": "^9.27.0",
120
+ "cspell": "^9.1.1",
121
+ "eslint": "^9.29.0",
122
122
  "markdownlint": "^0.38.0",
123
123
  "vite": "^6.3.5",
124
- "vitest": "^3.1.4"
124
+ "vitest": "^3.2.3"
125
125
  },
126
126
  "keywords": []
127
127
  }