@ale0aranda/rules 0.1.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.
Files changed (3) hide show
  1. package/biome.json +177 -0
  2. package/commitlint.mjs +89 -0
  3. package/package.json +63 -0
package/biome.json ADDED
@@ -0,0 +1,177 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "files": {
4
+ "ignoreUnknown": true,
5
+ "includes": [
6
+ "**",
7
+ "!!**/node_modules",
8
+ "!!**/dist",
9
+ "!!**/build",
10
+ "!!**/out",
11
+ "!!**/.next",
12
+ "!!**/.astro",
13
+ "!!**/.turbo",
14
+ "!!**/.cache",
15
+ "!!**/coverage",
16
+ "!!**/playwright-report",
17
+ "!!**/test-results",
18
+ "!**/*.min.*",
19
+ "!**/*.generated.*",
20
+ "!**/generated"
21
+ ]
22
+ },
23
+ "vcs": {
24
+ "enabled": true,
25
+ "clientKind": "git",
26
+ "useIgnoreFile": true
27
+ },
28
+ "formatter": {
29
+ "enabled": true,
30
+ "formatWithErrors": false,
31
+ "attributePosition": "multiline",
32
+ "bracketSameLine": false,
33
+ "bracketSpacing": true,
34
+ "expand": "auto",
35
+ "indentStyle": "space",
36
+ "indentWidth": 2,
37
+ "lineEnding": "lf",
38
+ "lineWidth": 80,
39
+ "trailingNewline": true
40
+ },
41
+ "linter": {
42
+ "enabled": true,
43
+ "rules": {
44
+ "preset": "recommended",
45
+ "correctness": {
46
+ "noUnusedImports": "error",
47
+ "noUnusedVariables": "warn"
48
+ },
49
+ "style": {
50
+ "noNonNullAssertion": "warn",
51
+ "useImportType": "error"
52
+ },
53
+ "suspicious": {
54
+ "noConsole": "warn",
55
+ "noExplicitAny": "error"
56
+ },
57
+ "nursery": {
58
+ "noTailwindArbitraryValue": {
59
+ "level": "error",
60
+ "options": {
61
+ "functions": ["cn", "clsx"]
62
+ }
63
+ },
64
+ "useSortedClasses": {
65
+ "level": "warn",
66
+ "options": {
67
+ "functions": ["cn", "clsx"]
68
+ }
69
+ }
70
+ }
71
+ }
72
+ },
73
+ "assist": {
74
+ "enabled": true,
75
+ "actions": {
76
+ "source": {
77
+ "organizeImports": {
78
+ "level": "on",
79
+ "options": {
80
+ "sortBareImports": false,
81
+ "groups": [
82
+ {
83
+ "type": false,
84
+ "source": [":BUN:", ":NODE:"]
85
+ },
86
+ ":BLANK_LINE:",
87
+ {
88
+ "type": false,
89
+ "source": [
90
+ ":PACKAGE_WITH_PROTOCOL:",
91
+ ":PACKAGE:",
92
+ "!@ale0aranda/**"
93
+ ]
94
+ },
95
+ ":BLANK_LINE:",
96
+ {
97
+ "type": false,
98
+ "source": "@ale0aranda/**"
99
+ },
100
+ ":BLANK_LINE:",
101
+ {
102
+ "type": false,
103
+ "source": ":ALIAS:"
104
+ },
105
+ ":BLANK_LINE:",
106
+ {
107
+ "type": false,
108
+ "source": ":PATH:"
109
+ },
110
+ ":BLANK_LINE:",
111
+ {
112
+ "type": true
113
+ }
114
+ ]
115
+ }
116
+ }
117
+ }
118
+ }
119
+ },
120
+ "javascript": {
121
+ "formatter": {
122
+ "arrowParentheses": "always",
123
+ "attributePosition": "multiline",
124
+ "bracketSameLine": false,
125
+ "bracketSpacing": true,
126
+ "jsxQuoteStyle": "single",
127
+ "operatorLinebreak": "before",
128
+ "quoteProperties": "asNeeded",
129
+ "quoteStyle": "single",
130
+ "semicolons": "always",
131
+ "trailingCommas": "none"
132
+ }
133
+ },
134
+ "css": {
135
+ "formatter": {
136
+ "enabled": true,
137
+ "quoteStyle": "single"
138
+ },
139
+ "linter": {
140
+ "enabled": true
141
+ },
142
+ "parser": {
143
+ "tailwindDirectives": true
144
+ }
145
+ },
146
+ "html": {
147
+ "formatter": {
148
+ "enabled": true,
149
+ "attributePosition": "multiline",
150
+ "bracketSameLine": false,
151
+ "indentScriptAndStyle": true
152
+ },
153
+ "linter": {
154
+ "enabled": true
155
+ }
156
+ },
157
+ "json": {
158
+ "formatter": {
159
+ "enabled": true,
160
+ "expand": "auto",
161
+ "indentStyle": "space",
162
+ "indentWidth": 2,
163
+ "lineWidth": 80,
164
+ "trailingCommas": "none",
165
+ "trailingNewline": true
166
+ }
167
+ },
168
+ "graphql": {
169
+ "formatter": {
170
+ "enabled": true,
171
+ "quoteStyle": "single"
172
+ },
173
+ "linter": {
174
+ "enabled": true
175
+ }
176
+ }
177
+ }
package/commitlint.mjs ADDED
@@ -0,0 +1,89 @@
1
+ import { createRequire } from 'node:module';
2
+
3
+ import conventional from '@commitlint/config-conventional';
4
+ import createPreset from 'conventional-changelog-conventionalcommits';
5
+ import { merge } from 'lodash-es';
6
+
7
+ const require = createRequire(import.meta.url);
8
+
9
+ const { types } = require('conventional-commit-types-emoji');
10
+
11
+ const commitTypes = Object.fromEntries(
12
+ Object.entries(types).map(([type, value]) => {
13
+ const [emoji, ...description] = value.description.trim().split(/\s+/);
14
+
15
+ return [
16
+ type,
17
+ {
18
+ emoji,
19
+ title: type,
20
+ description: description.join(' ')
21
+ }
22
+ ];
23
+ })
24
+ );
25
+
26
+ const emojiPattern = Object.values(commitTypes)
27
+ .map(({ emoji }) => emoji)
28
+ .join('|');
29
+
30
+ const parserOpts = {
31
+ headerPattern: new RegExp(
32
+ `^(?:${emojiPattern})\\s+(\\w*)(?:\\((.*)\\))?!?:\\s+(.*)$`
33
+ ),
34
+
35
+ breakingHeaderPattern: new RegExp(
36
+ `^(?:${emojiPattern})\\s+(\\w*)(?:\\((.*)\\))?!:\\s+(.*)$`
37
+ ),
38
+
39
+ headerCorrespondence: ['type', 'scope', 'subject']
40
+ };
41
+
42
+ const parserPreset = merge({}, await createPreset(), {
43
+ conventionalChangelog: {
44
+ parserOpts
45
+ },
46
+
47
+ parserOpts,
48
+
49
+ recommendedBumpOpts: {
50
+ parserOpts
51
+ }
52
+ });
53
+
54
+ /** @type {import("@commitlint/types").UserConfig} */
55
+ const config = {
56
+ ...conventional,
57
+
58
+ parserPreset,
59
+
60
+ rules: {
61
+ ...conventional.rules,
62
+
63
+ 'body-leading-blank': [2, 'always'],
64
+ 'footer-leading-blank': [2, 'always'],
65
+ 'header-max-length': [2, 'always', 100],
66
+ 'scope-case': [2, 'always', 'kebab-case'],
67
+ 'subject-empty': [2, 'never'],
68
+ 'subject-full-stop': [2, 'never', '.'],
69
+ 'type-case': [2, 'always', 'lower-case'],
70
+ 'type-empty': [2, 'never'],
71
+ 'type-enum': [2, 'always', Object.keys(commitTypes)]
72
+ },
73
+
74
+ prompt: {
75
+ ...conventional.prompt,
76
+
77
+ questions: {
78
+ ...conventional.prompt?.questions,
79
+
80
+ type: {
81
+ description: 'Select the exchange rate:',
82
+ enum: commitTypes,
83
+ headerWithEmoji: true
84
+ }
85
+ }
86
+ }
87
+ };
88
+
89
+ export default config;
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@ale0aranda/rules",
3
+ "version": "0.1.0",
4
+ "description": "Shared Biome and Commitlint rules for Alejandro Aranda's projects.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Alejandro Aranda",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ale0aranda/rules.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/ale0aranda/rules/issues"
14
+ },
15
+ "homepage": "https://github.com/ale0aranda/rules#readme",
16
+ "keywords": [
17
+ "biome",
18
+ "commitlint",
19
+ "conventional-commits",
20
+ "emoji",
21
+ "lint",
22
+ "formatter",
23
+ "shared-config"
24
+ ],
25
+ "files": [
26
+ "biome.json",
27
+ "commitlint.mjs",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "exports": {
32
+ "./biome": "./biome.json",
33
+ "./commitlint": "./commitlint.mjs",
34
+ "./package.json": "./package.json"
35
+ },
36
+ "engines": {
37
+ "node": ">=22.12.0"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "provenance": true
42
+ },
43
+ "devDependencies": {
44
+ "@biomejs/biome": "^2.5.11",
45
+ "@commitlint/cli": "^21.2.2",
46
+ "@commitlint/lint": "^21.2.2",
47
+ "@commitlint/load": "^21.2.2",
48
+ "@commitlint/types": "^21.2.0"
49
+ },
50
+ "dependencies": {
51
+ "@commitlint/config-conventional": "^21.2.2",
52
+ "conventional-changelog-conventionalcommits": "^10.4.0",
53
+ "conventional-commit-types-emoji": "^0.1.0",
54
+ "lodash-es": "^4.18.1"
55
+ },
56
+ "scripts": {
57
+ "check": "pnpm check:biome && pnpm check:commitlint && pnpm check:package",
58
+ "check:biome": "biome ci .",
59
+ "check:commitlint": "node --test test/commitlint.test.mjs",
60
+ "check:package": "node --test test/package.test.mjs",
61
+ "format": "biome check --write ."
62
+ }
63
+ }