You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-7Lines changed: 2 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,12 +28,6 @@ The name was coined in fall 2016 and changed around spring 2017.
28
28
29
29
## Contributors
30
30
31
-
### YOU?!
32
-
33
-
New -- Feb 2022: If you want to work on something at https://github.com/sagemathinc/cocalc/issues, [contact us](email:[email protected]), and we might be able to pay you!
34
-
35
-
### Contributors
36
-
37
31
- Greg Bard
38
32
- Rob Beezer
39
33
- Blaec Bejarano
@@ -52,7 +46,7 @@ New -- Feb 2022: If you want to work on something at https://github.com/sagemat
52
46
- Jonathan Thompson
53
47
- Todd Zimmerman
54
48
55
-
... and _many_others: See https://github.com/sagemathinc/cocalc/graphs/contributors
49
+
... and others: See https://github.com/sagemathinc/cocalc/graphs/contributors
56
50
57
51
## Copyright/License
58
52
@@ -92,3 +86,4 @@ We are grateful to BrowserStack for providing infrastructure to test CoCalc.
92
86
### Google
93
87
94
88
We thank Google for donating over \$150K in cloud credits since 2014 to support this project.
- Use the _defaults_ with the latest version of prettier on all of our Javascript and Typescript code.
3
+
## Language (Javascript/Typescript/Python)
4
4
5
-
-Language: Always prefer Typescript over Javascript and CoffeeScript
5
+
-Prettier: Use the _defaults_ with the latest version of prettier on all of our Javascript and Typescript code. Use yapf for Python.
6
6
7
-
- Use the standard Javascript camelCase convention for variable names, unless there is a good reason otherwise. Good reasons include: variable names that are also used in PostgreSQL and interop with Python (lower case with underscores).
7
+
- NOTE: prettier's defaults change over time, but we don't ever just run it on our full massive codebase.
8
8
9
-
-React: Always prefer functional components over class components
9
+
-Typescript: Always prefer Typescript over Javascript and CoffeeScript
10
10
11
-
- React: Use the style of https://react.dev/learn/typescript for React with Typescript. In particular, use
11
+
- NOTE: there's still some coffeescript code in CoCalc; it's terrifying and should all be rewritten in Typescript.
12
+
13
+
- Variable Names: Use the standard Javascript camelCase convention for variable names, unless there is a good reason otherwise. Good reasons include: variable names that are also used in PostgreSQL and interop with Python (lower case with underscores).
14
+
15
+
- NOTE: there's a lot of Javascript code in cocalc that uses Python conventions. Long ago Nicholas R. argued "by using Python conventions we can easily distinguish our code from other code"; in retrospect, this was a bad argument, and only serves to make Javascript devs less comfortable in our codebase, and make our code look weird compared to most Javascript code. Rewrite it.
16
+
17
+
- Javascript Methods: Prefer arrow functions for methods of classes.
18
+
19
+
- it's standard
20
+
- avoids subtle problems involving "this" binding
21
+
- easier to search for function definition in editor
22
+
- NOTE: there's a lot of code in cocalc that uses non-arrow-functions; rewrite it and don't add more of this.
23
+
24
+
- Async Programming: Prefer async/await to callbacks if at all possible.
25
+
26
+
- NOTE: CoCalc used to not use async/await or promises at all, so there is still some code that uses the callback [async library](https://github.com/caolan/async). This code is terrifying, and it should all be rewritten.
27
+
28
+
## React
29
+
30
+
- Functional Components and hooks: Always prefer functional components with hooks over class components
31
+
32
+
- NOTE: there are still a lot of class components in cocalc; rewrite them.
33
+
34
+
- Use the style of https://react.dev/learn/typescript for React with Typescript:
35
+
- typescript detects unused props,
36
+
- defaults are natural and do not need MyButton.defaultProps, which is deprecated,
37
+
- uses minimal notation (less characters typed),
38
+
- very common in tutorials and other code
39
+
- NOTE: a lot of our code used to be class components, hence still is written like `prop.[propname]`
40
+
41
+
In particular, use
12
42
13
43
```ts
14
44
function MyButton({ title, disabled }:MyButtonProps) {
@@ -24,17 +54,28 @@ function MyButton(props: MyButtonProps) {
- it's far better to render 20 items slowly, e.g., using virtualization, then to render 20000 items quickly
69
+
- NOTE: there's 100\+ uses of React.memo in cocalc right now; I'm not happy with this, though I wrote them. It's almost always a bad idea.
70
+
71
+
## UI Design
72
+
73
+
- As much as possible, use [Antd components](https://ant.design/) in the standard way.
74
+
75
+
- Avoid doing new design if possible; use the conventions and components of Antd.
76
+
- If there is a cancel button next to another button, then cancel goes first, following the Antd convention, e.g., see Popconfirm.
77
+
- NOTE: We wrote a lot of custom components, e.g., for number input, before switching fully to Antd, and those are still partly in use. Rewrite all of that to use Antd.
36
78
37
-
- typescript detects unused props,
38
-
- defaults are natural and do not need MyButton.defaultProps, which is deprecated,
39
-
- uses minimal notation (less characters typed),
40
-
- very common in tutorials and other code
79
+
- Bootstrap:
80
+
- CoCalc used to use jquery + bootstrap (way before react even existed!) for everything, and that's still in use for some things today (e.g., Sage Worksheets). Rewrite or delete all this.
81
+
- CoCalc also used to use react-bootstrap, and sadly still does. Get rid of this.
0 commit comments