@dimasbaguspm/versaur 0.0.9 → 0.0.10
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 +24 -1
- package/dist/enforce-subpath-import.js +107 -98
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
A modern React UI library built with TypeScript and Tailwind CSS, featuring tree-shakable
|
|
4
4
|
components
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
## Features
|
|
7
8
|
|
|
8
9
|
- 🎨 **Tailwind CSS 4** - Modern styling with CSS-in-JS
|
|
@@ -33,9 +34,31 @@ import { Button, Input, Card } from '@dimasbaguspm/versaur'
|
|
|
33
34
|
|
|
34
35
|
```tsx
|
|
35
36
|
// Import only what you need
|
|
36
|
-
import { Button } from 'versaur/primitive'
|
|
37
|
+
import { Button } from '@dimasbaguspm/versaur/primitive'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## ESLint: Enforce Sub-path Imports (FlatConfig)
|
|
42
|
+
|
|
43
|
+
Versaur provides an ESLint rule to enforce sub-path imports for optimal tree-shaking
|
|
44
|
+
|
|
45
|
+
**Setup:**
|
|
46
|
+
|
|
47
|
+
1. In your FlatConfig file (e.g., `eslint.config.js`), import and spread the rule:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
// eslint.config.js
|
|
51
|
+
import { versaurEnforceSubpathImport } from '@dimasbaguspm/versaur/enforce-subpath-import'
|
|
52
|
+
|
|
53
|
+
export default [
|
|
54
|
+
...versaurEnforceSubpathImport,
|
|
55
|
+
// ...other config
|
|
56
|
+
]
|
|
37
57
|
```
|
|
38
58
|
|
|
59
|
+
**What it does:**
|
|
60
|
+
|
|
61
|
+
Warns when importing from `@dimasbaguspm/versaur` directly, and suggests using sub-path imports (e.g., `@dimasbaguspm/versaur/primitive`) for better tree-shaking
|
|
39
62
|
|
|
40
63
|
## License
|
|
41
64
|
|
|
@@ -1,106 +1,115 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ESLint
|
|
2
|
+
* ESLint rule for Versaur: enforce sub-path imports for optimal tree-shaking (Flat config compatible)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
PageLayout: 'layouts',
|
|
53
|
-
TopBar: 'layouts',
|
|
54
|
-
// feedbacks
|
|
55
|
-
LoadingIndicator: 'feedbacks',
|
|
56
|
-
ProgressIndicator: 'feedbacks',
|
|
57
|
-
Skeleton: 'feedbacks',
|
|
58
|
-
// forms
|
|
59
|
-
CalculatorInput: 'forms',
|
|
60
|
-
CheckboxInput: 'forms',
|
|
61
|
-
ChipInput: 'forms',
|
|
62
|
-
DateSinglePickerInput: 'forms',
|
|
63
|
-
RadioInput: 'forms',
|
|
64
|
-
SegmentMultipleInput: 'forms',
|
|
65
|
-
SegmentSingleInput: 'forms',
|
|
66
|
-
SelectInput: 'forms',
|
|
67
|
-
SwitchInput: 'forms',
|
|
68
|
-
TextInput: 'forms',
|
|
69
|
-
TextareaInput: 'forms',
|
|
70
|
-
TimePickerInput: 'forms',
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Find first known symbol
|
|
74
|
-
const known = importSpecifiers.find(name => symbolToSubpath[name])
|
|
75
|
-
const subpath = known ? symbolToSubpath[known] : null
|
|
76
|
-
|
|
77
|
-
let message =
|
|
78
|
-
'Use sub-path import for better tree-shaking (e.g., @dimasbaguspm/versaur/primitive)'
|
|
79
|
-
if (subpath) {
|
|
80
|
-
message = `Import { ${known} } from '@dimasbaguspm/versaur/${subpath}' instead.`
|
|
81
|
-
}
|
|
5
|
+
const symbolToSubpath = {
|
|
6
|
+
// primitive
|
|
7
|
+
Button: 'primitive',
|
|
8
|
+
ButtonFloat: 'primitive',
|
|
9
|
+
ButtonIcon: 'primitive',
|
|
10
|
+
Avatar: 'primitive',
|
|
11
|
+
Badge: 'primitive',
|
|
12
|
+
Brand: 'primitive',
|
|
13
|
+
Calculator: 'primitive',
|
|
14
|
+
Calendar: 'primitive',
|
|
15
|
+
Icon: 'primitive',
|
|
16
|
+
Snackbar: 'primitive',
|
|
17
|
+
Table: 'primitive',
|
|
18
|
+
Text: 'primitive',
|
|
19
|
+
Tile: 'primitive',
|
|
20
|
+
Alert: 'primitive',
|
|
21
|
+
// overlays
|
|
22
|
+
Drawer: 'overlays',
|
|
23
|
+
Modal: 'overlays',
|
|
24
|
+
Menu: 'overlays',
|
|
25
|
+
// navigation
|
|
26
|
+
Tabs: 'navigation',
|
|
27
|
+
Breadcrumbs: 'navigation',
|
|
28
|
+
// layouts
|
|
29
|
+
AppBar: 'layouts',
|
|
30
|
+
BottomBar: 'layouts',
|
|
31
|
+
FormLayout: 'layouts',
|
|
32
|
+
PageLayout: 'layouts',
|
|
33
|
+
TopBar: 'layouts',
|
|
34
|
+
// feedbacks
|
|
35
|
+
LoadingIndicator: 'feedbacks',
|
|
36
|
+
ProgressIndicator: 'feedbacks',
|
|
37
|
+
Skeleton: 'feedbacks',
|
|
38
|
+
// forms
|
|
39
|
+
CalculatorInput: 'forms',
|
|
40
|
+
CheckboxInput: 'forms',
|
|
41
|
+
ChipInput: 'forms',
|
|
42
|
+
DateSinglePickerInput: 'forms',
|
|
43
|
+
RadioInput: 'forms',
|
|
44
|
+
SegmentMultipleInput: 'forms',
|
|
45
|
+
SegmentSingleInput: 'forms',
|
|
46
|
+
SelectInput: 'forms',
|
|
47
|
+
SwitchInput: 'forms',
|
|
48
|
+
TextInput: 'forms',
|
|
49
|
+
TextareaInput: 'forms',
|
|
50
|
+
TimePickerInput: 'forms',
|
|
51
|
+
}
|
|
82
52
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
53
|
+
const rules = {
|
|
54
|
+
meta: {
|
|
55
|
+
id: 'versaur-enforce-subpath-import',
|
|
56
|
+
name: 'versaur-enforce-subpath-import',
|
|
57
|
+
type: 'suggestion',
|
|
58
|
+
docs: {
|
|
59
|
+
description: 'Prefer sub-path imports for @dimasbaguspm/versaur',
|
|
60
|
+
},
|
|
61
|
+
fixable: 'code',
|
|
62
|
+
hasSuggestions: true,
|
|
63
|
+
},
|
|
64
|
+
create(context) {
|
|
65
|
+
return {
|
|
66
|
+
ImportDeclaration(node) {
|
|
67
|
+
if (node.source.value === '@dimasbaguspm/versaur') {
|
|
68
|
+
const importSpecifiers = node.specifiers
|
|
69
|
+
.filter(s => s.type === 'ImportSpecifier')
|
|
70
|
+
.map(s => s.imported.name)
|
|
71
|
+
const known = importSpecifiers.find(name => symbolToSubpath[name])
|
|
72
|
+
const subpath = known ? symbolToSubpath[known] : null
|
|
73
|
+
let message =
|
|
74
|
+
'Use sub-path import for better tree-shaking (e.g., @dimasbaguspm/versaur/primitive)'
|
|
75
|
+
if (subpath) {
|
|
76
|
+
message = `Import { ${known} } from '@dimasbaguspm/versaur/${subpath}' instead.`
|
|
77
|
+
}
|
|
78
|
+
context.report({
|
|
79
|
+
node,
|
|
80
|
+
message,
|
|
81
|
+
suggest: subpath
|
|
82
|
+
? [
|
|
83
|
+
{
|
|
84
|
+
desc: `Change to import { ${known} } from '@dimasbaguspm/versaur/${subpath}'`,
|
|
85
|
+
fix(fixer) {
|
|
86
|
+
return fixer.replaceText(
|
|
87
|
+
node.source,
|
|
88
|
+
`'@dimasbaguspm/versaur/${subpath}'`
|
|
89
|
+
)
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
]
|
|
93
|
+
: [],
|
|
94
|
+
})
|
|
102
95
|
}
|
|
103
96
|
},
|
|
104
|
-
}
|
|
97
|
+
}
|
|
105
98
|
},
|
|
106
99
|
}
|
|
100
|
+
|
|
101
|
+
// export array of config objects for flexible flat config usage
|
|
102
|
+
export const versaurEnforceSubpathImport = [
|
|
103
|
+
{
|
|
104
|
+
plugins: {
|
|
105
|
+
dimasbaguspm: {
|
|
106
|
+
rules: {
|
|
107
|
+
'versaur-enforce-subpath-import': rules,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
rules: {
|
|
112
|
+
'dimasbaguspm/versaur-enforce-subpath-import': 'warn',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimasbaguspm/versaur",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "React UI library with Tailwind CSS",
|
|
5
5
|
"author": "Dimas Bagus Prayogo Mukti<dimas.bagus.pm@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"import": "./dist/index.js",
|
|
15
15
|
"types": "./dist/index.d.ts"
|
|
16
16
|
},
|
|
17
|
+
"./primitive": {
|
|
18
|
+
"import": "./dist/primitive/index.js",
|
|
19
|
+
"types": "./dist/primitive/index.d.ts"
|
|
20
|
+
},
|
|
17
21
|
"./feedbacks": {
|
|
18
22
|
"import": "./dist/feedbacks/index.js",
|
|
19
23
|
"types": "./dist/feedbacks/index.d.ts"
|