Skip to content

Commit bd1cddf

Browse files
authored
feat: add stylelint (#290)
1 parent f0760be commit bd1cddf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+799
-378
lines changed

.electron-vendors.cache.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"chrome": "96",
3-
"node": "16"
2+
"chrome": "96",
3+
"node": "16"
44
}

.eslintrc.json

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
"ecmaVersion": 12,
1717
"sourceType": "module"
1818
},
19-
"plugins": [
20-
"@typescript-eslint"
21-
],
19+
"plugins": ["@typescript-eslint"],
2220
"ignorePatterns": [
2321
"packages/preload/exposedInMainWorld.d.ts",
2422
"node_modules/**",
@@ -38,25 +36,17 @@
3836
"vue/singleline-html-element-content-newline": ["off"],
3937
"no-undef": "off",
4038
/**
41-
* Having a semicolon helps the optimizer interpret your code correctly.
42-
* This avoids rare errors in optimized code.
43-
*/
44-
"semi": [
45-
"error",
46-
"always"
47-
],
39+
* Having a semicolon helps the optimizer interpret your code correctly.
40+
* This avoids rare errors in optimized code.
41+
*/
42+
"semi": ["error", "always"],
4843
/**
49-
* This will make the history of changes in the hit a little cleaner
50-
*/
51-
"comma-dangle": [
52-
"warn",
53-
"always-multiline"
54-
],
44+
* This will make the history of changes in the hit a little cleaner
45+
*/
46+
"comma-dangle": ["warn", "always-multiline"],
5547
/**
56-
* Just for beauty
57-
*/
58-
"quotes": [
59-
"warn", "single"
60-
]
48+
* Just for beauty
49+
*/
50+
"quotes": ["warn", "single"]
6151
}
6252
}

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ about: Create a report to help us improve
44
title: ''
55
labels: bug
66
assignees: cawa-93
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
44
title: ''
55
labels: enhancement
66
assignees: cosmic
7-
87
---
98

109
**Is your feature request related to a problem? Please describe.**

.github/renovate.json

Lines changed: 33 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,37 @@
11
{
2-
"extends": [
3-
"config:base",
4-
":semanticCommits",
5-
":automergeTypes",
6-
":disableDependencyDashboard"
7-
],
8-
"labels": [
9-
"dependencies"
10-
],
11-
"baseBranches": [
12-
"main"
13-
],
14-
"bumpVersion": "patch",
15-
"patch": {
16-
"automerge": true
17-
},
18-
"minor": {
19-
"automerge": true
20-
},
21-
"packageRules": [
22-
{
23-
"packageNames": [
24-
"node",
25-
"npm"
26-
],
27-
"enabled": false
2+
"extends": ["config:base", ":semanticCommits", ":automergeTypes", ":disableDependencyDashboard"],
3+
"labels": ["dependencies"],
4+
"baseBranches": ["main"],
5+
"bumpVersion": "patch",
6+
"patch": {
7+
"automerge": true
288
},
29-
{
30-
"depTypeList": [
31-
"devDependencies"
32-
],
33-
"semanticCommitType": "build"
9+
"minor": {
10+
"automerge": true
3411
},
35-
{
36-
"matchSourceUrlPrefixes": [
37-
"https://github.com/searchfe/cosmic/"
38-
],
39-
"groupName": "Vite monorepo packages",
40-
"automerge": false
41-
},
42-
{
43-
"matchPackagePatterns": [
44-
"^@typescript-eslint",
45-
"^eslint"
46-
],
47-
"automerge": true,
48-
"groupName": "eslint"
49-
},
50-
{
51-
"matchPackageNames": [
52-
"electron"
53-
],
54-
"separateMajorMinor": false
55-
}
56-
],
57-
"rangeStrategy": "pin"
12+
"packageRules": [
13+
{
14+
"packageNames": ["node", "npm"],
15+
"enabled": false
16+
},
17+
{
18+
"depTypeList": ["devDependencies"],
19+
"semanticCommitType": "build"
20+
},
21+
{
22+
"matchSourceUrlPrefixes": ["https://github.com/searchfe/cosmic/"],
23+
"groupName": "Vite monorepo packages",
24+
"automerge": false
25+
},
26+
{
27+
"matchPackagePatterns": ["^@typescript-eslint", "^eslint"],
28+
"automerge": true,
29+
"groupName": "eslint"
30+
},
31+
{
32+
"matchPackageNames": ["electron"],
33+
"separateMajorMinor": false
34+
}
35+
],
36+
"rangeStrategy": "pin"
5837
}

.prettierignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.stylelintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "@ecomfe/stylelint-config",
3+
"ignoreFiles": ["**/dist/**", "**/node_modules/**"]
4+
5+
}

README.md

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,110 @@
1-
# Cosmic
1+
# Cosmic
22

33
[![GitHub issues by-label](https://img.shields.io/github/issues/searchfe/cosmic/help%20wanted?label=issues%20need%20help&logo=github)](https://github.com/searchfe/cosmic/issues?q=label%3A%22help+wanted%22+is%3Aopen+is%3Aissue)
44
[![Required Node.JS >= v16.13](https://img.shields.io/static/v1?label=node&message=%3E=16.13&logo=node.js&color)](https://nodejs.org/about/releases/)
55
[![Required npm >= v8.1](https://img.shields.io/static/v1?label=npm&message=%3E=8.1&logo=npm&color)](https://github.com/npm/cli/releases)
66

7-
87
Cosmic is the free and open source ui design suite. It supports the entirety of the prototype, visual design, animation, component package and code release.
98

10-
119
## Get started
1210

1311
### Continuous Integration
14-
- The configured workflow will check the types for each push and PR.
15-
- The configured workflow will check the code style for each push and PR.
16-
- Unit tests are placed within each package and run separately.
17-
- End-to-end tests are placed in the root [`tests`](tests) directory and use [playwright].
12+
13+
- The configured workflow will check the types for each push and PR.
14+
- The configured workflow will check the code style for each push and PR.
15+
- Unit tests are placed within each package and run separately.
16+
- End-to-end tests are placed in the root [`tests`](tests) directory and use [playwright].
1817

1918
### Continuous delivery
20-
- Each time you push changes to the `main` branch, the [`release`](.github/workflows/release.yml) workflow starts, which creates a release draft.
21-
- The version is automatically set based on the current date in the format `yy.mm.dd-minutes`.
22-
- Notes are automatically generated and added to the release draft.
23-
- Code signing supported. See [`compile` job in the `release` workflow](.github/workflows/release.yml).
24-
- **Auto-update is supported**. After the release is published, all client applications will download the new version and install updates silently.
19+
20+
- Each time you push changes to the `main` branch, the [`release`](.github/workflows/release.yml) workflow starts, which creates a release draft.
21+
- The version is automatically set based on the current date in the format `yy.mm.dd-minutes`.
22+
- Notes are automatically generated and added to the release draft.
23+
- Code signing supported. See [`compile` job in the `release` workflow](.github/workflows/release.yml).
24+
- **Auto-update is supported**. After the release is published, all client applications will download the new version and install updates silently.
2525

2626
### Project Structure
2727

2828
The structure of this template is very similar to the structure of a monorepo.
2929

3030
The entire source code of the program is divided into three modules (packages) that are each bundled independently:
31-
- [`packages/app`](packages/app)
32-
Electron [**main script**](https://www.electronjs.org/docs/tutorial/quick-start#create-the-main-script-file).
33-
- [`packages/preload`](packages/preload)
34-
Used in `BrowserWindow.webPreferences.preload`. See [Checklist: Security Recommendations](https://www.electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content).
35-
- [`packages/site`](packages/site)
36-
Electron [**web page**](https://www.electronjs.org/docs/tutorial/quick-start#create-a-web-page).
37-
- [`packages/core`](packages/core)
38-
Core libs for cosmic.
39-
- [`packages/module`](packages/module)
40-
Modules for cosmic.
31+
32+
- [`packages/app`](packages/app)
33+
Electron [**main script**](https://www.electronjs.org/docs/tutorial/quick-start#create-the-main-script-file).
34+
- [`packages/preload`](packages/preload)
35+
Used in `BrowserWindow.webPreferences.preload`. See [Checklist: Security Recommendations](https://www.electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content).
36+
- [`packages/site`](packages/site)
37+
Electron [**web page**](https://www.electronjs.org/docs/tutorial/quick-start#create-a-web-page).
38+
- [`packages/core`](packages/core)
39+
Core libs for cosmic.
40+
- [`packages/module`](packages/module)
41+
Modules for cosmic.
4142

4243
### Compile App
44+
4345
The next step is to package and compile a ready to distribute Electron app for macOS, Windows and Linux with "auto update" support out of the box.
4446

4547
To do this using the [electron-builder]:
46-
- Using the npm script `compile`: This script is configured to compile the application as quickly as possible. It is not ready for distribution, it is compiled only for the current platform and is used for debugging.
47-
- Using GitHub Actions: The application is compiled for any platform and ready-to-distribute files are automatically added as a draft to the GitHub releases page.
48+
49+
- Using the npm script `compile`: This script is configured to compile the application as quickly as possible. It is not ready for distribution, it is compiled only for the current platform and is used for debugging.
50+
- Using GitHub Actions: The application is compiled for any platform and ready-to-distribute files are automatically added as a draft to the GitHub releases page.
4851

4952
### Using external modules in renderer
53+
5054
According to [Electron's security guidelines](https://www.electronjs.org/docs/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content), Node.js integration is disabled for remote content. This means that **you cannot call any Node.js api in the `packages/site` directly**. This also means you can't import external modules during runtime in the renderer:
55+
5156
```js
5257
// renderer.bundle.js
53-
const {writeFile} = require('fs') // ReferenceError: require is not defined
54-
writeFile()
58+
const { writeFile } = require('fs'); // ReferenceError: require is not defined
59+
writeFile();
5560
```
5661

5762
To use external modules in Renderer you **must** describe the interface in the `packages/preload` where the Node.js api is allowed:
63+
5864
```ts
5965
// packages/preload/src/index.ts
60-
import type {BinaryLike} from 'crypto';
61-
import {createHash} from 'crypto';
66+
import type { BinaryLike } from 'crypto';
67+
import { createHash } from 'crypto';
6268

6369
contextBridge.exposeInMainWorld('nodeCrypto', {
64-
sha256sum(data: BinaryLike) {
65-
const hash = createHash('sha256');
66-
hash.update(data);
67-
return hash.digest('hex');
68-
},
70+
sha256sum(data: BinaryLike) {
71+
const hash = createHash('sha256');
72+
hash.update(data);
73+
return hash.digest('hex');
74+
},
6975
});
7076
```
7177

7278
The [`dts-cb`](https://github.com/cawa-93/dts-for-context-bridge) utility will automatically generate an interface for TS:
79+
7380
```ts
74-
// packages/preload/exposedInMainWorld.d.ts
81+
// packages/preload/exposedInMainWorld.d.ts
7582
interface Window {
76-
readonly nodeCrypto: { sha256sum(data: import("crypto").BinaryLike): string; };
83+
readonly nodeCrypto: { sha256sum(data: import('crypto').BinaryLike): string };
7784
}
7885
```
86+
7987
And now, you can safely use the registered method:
88+
8089
```ts
8190
// packages/site/src/App.vue
82-
window.nodeCrypto.sha256sum('data')
91+
window.nodeCrypto.sha256sum('data');
8392
```
8493

8594
[Read more about Security Considerations](https://www.electronjs.org/docs/tutorial/context-isolation#security-considerations).
8695

87-
8896
### Modes and Environment Variables
97+
8998
All environment variables set as part of the `import.meta`, so you can access them as follows: `import.meta.env`.
9099

91100
If you are using TypeScript and want to get code completion you must add all the environment variables to the [`ImportMetaEnv` in `types/env.d.ts`](types/env.d.ts).
92101

93102
The mode option is used to specify the value of `import.meta.env.MODE` and the corresponding environment variables files that need to be loaded.
94103

95104
By default, there are two modes:
96-
- `production` is used by default
97-
- `development` is used by `npm run watch` script
105+
106+
- `production` is used by default
107+
- `development` is used by `npm run watch` script
98108

99109
When running the build script, the environment variables are loaded from the following files in your project root:
100110

@@ -111,6 +121,7 @@ To prevent accidentally leaking env variables to the client, only variables pref
111121
DB_PASSWORD=foobar
112122
VITE_SOME_KEY=123
113123
```
124+
114125
Only `VITE_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to your client source code, but `DB_PASSWORD` will not.
115126

116127
**Do not put any sensitive data in files managed by git, for instance database password or server address in intranet**
@@ -119,7 +130,6 @@ Only `VITE_SOME_KEY` will be exposed as `import.meta.env.VITE_SOME_KEY` to your
119130

120131
See [Contributing Guide](contributing.md).
121132

122-
123133
[vite]: https://github.com/vitejs/vite/
124134
[electron]: https://github.com/electron/electron
125135
[electron-builder]: https://github.com/electron-userland/electron-builder

contributing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Do not create issues about bumping dependencies unless a bug has been identified
1010

1111
Remember that we’re here to help, but not to make guesses about what you need help with:
1212

13-
- Whatever bug or issue you're experiencing, assume that it will not be as obvious to the maintainers as it is to you.
14-
- Spell it out completely. Keep in mind that maintainers need to think about _all potential use cases_ of a library. It's important that you explain how you're using a library so that maintainers can make that connection and solve the issue.
13+
- Whatever bug or issue you're experiencing, assume that it will not be as obvious to the maintainers as it is to you.
14+
- Spell it out completely. Keep in mind that maintainers need to think about _all potential use cases_ of a library. It's important that you explain how you're using a library so that maintainers can make that connection and solve the issue.
1515

1616
_It can't be understated how frustrating and draining it can be to maintainers to have to ask clarifying questions on the most basic things, before it's even possible to start debugging. Please try to make the best use of everyone's time involved, including yourself, by providing this information up front._
1717

18-
1918
## Repo Setup
19+
2020
The package manager used to install and link dependencies must be npm v7 or later.
2121

2222
1. Clone repo

0 commit comments

Comments
 (0)