Skip to content

Commit 22748ea

Browse files
authored
Merge pull request #86 from xandemon/feat/config-updates
feat: config updates and new workflow for formatting, linting, type checks, pre-commits, etc.
2 parents 01028dc + 1a6ec6c commit 22748ea

34 files changed

Lines changed: 1128 additions & 156 deletions

.eslintrc.cjs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,32 @@ module.exports = {
22
root: true,
33
env: { browser: true, es2020: true },
44
extends: [
5-
'eslint:recommended',
6-
'plugin:@typescript-eslint/recommended',
7-
'plugin:react-hooks/recommended',
5+
"eslint:recommended",
6+
"plugin:@typescript-eslint/recommended",
7+
"plugin:react-hooks/recommended",
8+
"prettier",
89
],
9-
ignorePatterns: ['dist', '.eslintrc.cjs'],
10-
parser: '@typescript-eslint/parser',
11-
plugins: ['react-refresh'],
10+
ignorePatterns: ["dist", "showcase/dist", "lib/icons", ".eslintrc.cjs"],
11+
parser: "@typescript-eslint/parser",
12+
plugins: ["react-refresh"],
1213
rules: {
13-
'react-refresh/only-export-components': [
14-
'warn',
14+
"react-refresh/only-export-components": [
15+
"warn",
1516
{ allowConstantExport: true },
1617
],
1718
},
18-
}
19+
overrides: [
20+
{
21+
files: ["*.config.*", "lib/scripts/**/*.ts", "showcase/astro.config.mjs"],
22+
env: { node: true },
23+
},
24+
{
25+
files: ["showcase/src/components/ui/**/*.{ts,tsx}"],
26+
rules: { "react-refresh/only-export-components": "off" },
27+
},
28+
{
29+
files: ["**/env.d.ts"],
30+
rules: { "@typescript-eslint/triple-slash-reference": "off" },
31+
},
32+
],
33+
};

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cl
1212
polar: # Replace with a single Polar username
1313
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
1414
thanks_dev: # Replace with a single thanks.dev username
15-
custom: ['https://paypal.me/sandeshkatwal']
15+
custom: ["https://paypal.me/sandeshkatwal"]

.github/workflows/code-checks.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
verify:
10+
name: Code checks and build verification
11+
runs-on: ubuntu-latest
12+
env:
13+
HUSKY: "0"
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: "20"
22+
cache: npm
23+
cache-dependency-path: package-lock.json
24+
25+
- name: Install root dependencies
26+
run: npm ci
27+
28+
- name: Verify root package
29+
run: npm run verify:root
30+
31+
- name: Install showcase dependencies
32+
run: npm ci
33+
working-directory: showcase
34+
35+
- name: Build showcase
36+
run: npm run build
37+
working-directory: showcase

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.prettierignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dist
2+
dist-ssr
3+
node_modules
4+
showcase/dist
5+
showcase/.astro
6+
lib/icons
7+
*.min.js
8+
package-lock.json
9+
showcase/package-lock.json

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": ["prettier-plugin-astro"],
3+
"overrides": [
4+
{
5+
"files": "*.astro",
6+
"options": {
7+
"parser": "astro"
8+
}
9+
}
10+
]
11+
}

index.html

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
<!doctype html>
22
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Developer-Icons Playground</title>
8+
</head>
39

4-
<head>
5-
<meta charset="UTF-8" />
6-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<title>Developer-Icons Playground</title>
9-
</head>
10-
11-
<body>
12-
<div id="root"></div>
13-
<script type="module" src="/playground/main.tsx"></script>
14-
</body>
15-
16-
</html>
10+
<body>
11+
<div id="root"></div>
12+
<script type="module" src="/playground/main.tsx"></script>
13+
</body>
14+
</html>

lib/createDeveloperIcon.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import svgoConfig from "../svgo.config.mjs";
66
export const createDeveloperIcon = (
77
iconName: string,
88
iconContent: string,
9-
path: string
9+
path: string,
1010
) => {
1111
const optimizedSvg = optimize(iconContent, {
1212
path,
@@ -32,11 +32,11 @@ export const createDeveloperIcon = (
3232
return `${key}=${JSON.stringify(value)}`;
3333
}
3434
},
35-
})
35+
}),
3636
);
3737

3838
return `import { createElement } from 'react';\nimport {Icon, DeveloperIconProps} from '../icon';\nexport const ${iconName} = (props: DeveloperIconProps) => createElement(Icon, {...${JSON.stringify(
39-
sanitizedSvgObject.attributes
39+
sanitizedSvgObject.attributes,
4040
)}, ...props, children: [${children}]
4141
})`;
4242
};
@@ -49,15 +49,20 @@ const sanitizeStyles = (svgObject: INode) => {
4949
.trim();
5050

5151
if (styleString) {
52-
const styleObject = styleString.split(";").reduce((acc, style) => {
53-
const [key, value] = style.split(":").map((s) => s.trim());
54-
if (key && value) {
55-
// Convert kebab-case to camelCase
56-
const camelKey = key.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
57-
acc[camelKey] = value;
58-
}
59-
return acc;
60-
}, {} as Record<string, string>);
52+
const styleObject = styleString.split(";").reduce(
53+
(acc, style) => {
54+
const [key, value] = style.split(":").map((s) => s.trim());
55+
if (key && value) {
56+
// Convert kebab-case to camelCase
57+
const camelKey = key.replace(/-([a-z])/g, (g) =>
58+
g[1].toUpperCase(),
59+
);
60+
acc[camelKey] = value;
61+
}
62+
return acc;
63+
},
64+
{} as Record<string, string>,
65+
);
6166

6267
//@ts-expect-error string style is converted into object style
6368
modifiedSvgObject.attributes.style = styleObject;

lib/iconsData.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,13 @@ export const iconsData: IconDataType[] = [
13951395
name: "Microsoft SQL Server 2",
13961396
path: "icons/microsoft-sql-server-2.svg",
13971397
categories: ["Database", "Backend"],
1398-
keywords: ["microsoft-sql-server", "database", "sql", "microsoft", "enterprise"],
1398+
keywords: [
1399+
"microsoft-sql-server",
1400+
"database",
1401+
"sql",
1402+
"microsoft",
1403+
"enterprise",
1404+
],
13991405
url: "https://www.microsoft.com/en-us/sql-server",
14001406
},
14011407
{

lib/scripts/build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ iconsData.forEach((icon) => {
2020
const component = createDeveloperIcon(
2121
iconName,
2222
iconContent,
23-
path.join(svgDir, icon.path)
23+
path.join(svgDir, icon.path),
2424
);
2525
fs.writeFileSync(
2626
path.join(__dirname, "../icons", `${iconName}.tsx`),
27-
component
27+
component,
2828
);
2929

3030
exportStatement += `export * from './${iconName}.tsx';`;

0 commit comments

Comments
 (0)