Skip to content

Commit 8cf9f63

Browse files
committed
style: change style settings for better format standard
[#62] Refer to GitHub issue... This update does the followings to implement better coding style guide standard based on Airbnb Style Guide, ESLint, Prettier, and PEP8. .editorconfig - Added file to implement necessary format settings across different IDEs including VSCode. .eslintrc - Removed Typescript related extensions and plugins as it prompts ESLint unnecessary warnings. Will be implemented again once Typescript is used. - Import plugin added to lint import-related codes. - Several rules were included to overrule Prettier with Airbnb rules, which we figured were better coding practices. The followings are included: react/no-multi-comp semi, comma-dangle, no-underscore-dangle, space-before-blocks, keyword-spacing, spaced-comment, quotes, prefer-template, template-curly-spacing, jsx-quotes, camelcase, no-unused-vars. - Import rules were added to match with Airbnb style guide. - Rules are subject to change in the future and documentation regarding the changes will be written. .prettierrc - Some rules were changed to overrule Prettier with Airbnb rules. .vscode/settings.json - Editor indent setting was removed as it is now included in .editorconfig. package.json - Removed Typescript related extensions and will be implemented in the future once Typescript is used. - Airbnb related ESLint plugins were added to enforce Airbnb style guide rules. - StyleLint was added to organize CSS files. The tool is being tested and may be removed in the future.
1 parent 61951ee commit 8cf9f63

File tree

6 files changed

+6651
-3495
lines changed

6 files changed

+6651
-3495
lines changed

Diff for: .editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = false
10+
11+
# Python files
12+
[*.{py, pyi, pyc, pyd, pyo, pyw, pyz}]
13+
indent_size = 4

Diff for: .eslintrc

+63-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,66 @@
11
{
2-
"parser": "@typescript-eslint/parser",
3-
"extends": [
4-
"airbnb",
5-
"plugin:prettier/recommended",
6-
"plugin:react/recommended",
7-
"plugin:react-hooks/recommended",
8-
"plugin:jsx-a11y/recommended"
9-
],
10-
"plugins": ["prettier", "react"],
11-
"parserOptions": {
12-
"ecmaFeatures": {
13-
"jsx": true
14-
}
15-
},
16-
"rules": {
17-
"prettier/prettier": ["error"],
18-
"react-hooks/exhaustive-deps": "warn",
19-
"react-hooks/rules-of-hooks": "error",
20-
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
21-
"react/jsx-indent-props": [2, 4],
22-
"react/jsx-indent": [2, 4],
23-
"react/jsx-one-expression-per-line": [0],
24-
"react/prefer-stateless-function": [1],
25-
"react/static-property-placement": [1, "property assignment"]
2+
"extends": [
3+
"airbnb",
4+
"airbnb/hooks",
5+
"plugin:prettier/recommended",
6+
"plugin:react/recommended",
7+
"plugin:react-hooks/recommended",
8+
"plugin:jsx-a11y/recommended",
9+
"plugin:import/recommended"
10+
// "plugin:node/recommended"
11+
],
12+
"plugins": ["prettier", "react", "import"],
13+
"parserOptions": {
14+
"ecmaFeatures": {
15+
"jsx": true
2616
}
17+
},
18+
"rules": {
19+
"prettier/prettier": ["error"],
20+
21+
"react-hooks/exhaustive-deps": "warn",
22+
"react-hooks/rules-of-hooks": "error",
23+
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
24+
"react/jsx-indent-props": [2, 4],
25+
"react/jsx-indent": [2, 4],
26+
"react/jsx-one-expression-per-line": [0],
27+
"react/prefer-stateless-function": [1],
28+
"react/static-property-placement": [1, "property assignment"],
29+
"react/no-multi-comp": ["error", { "ignoreStateless": true }],
30+
31+
"semi": 2,
32+
"comma-dangle": "error",
33+
"no-underscore-dangle": "error",
34+
"space-before-blocks": "error",
35+
"keyword-spacing": "error",
36+
"spaced-comment": "error",
37+
"quotes": ["error", "single"],
38+
"prefer-template": "warn",
39+
"template-curly-spacing": ["error", "never"],
40+
"jsx-quotes": ["warn", "prefer-double"],
41+
"camelcase": ["error", { "properties": "always" }],
42+
"no-unused-vars": ["warn"],
43+
44+
"import/prefer-default-export": ["warn", { "target": "any" }],
45+
"import/no-duplicates": ["error", { "considerQueryString": true }],
46+
"import/order": [
47+
"error",
48+
{
49+
"groups": ["builtin", "external", "internal"],
50+
"pathGroups": [
51+
{
52+
"pattern": "react",
53+
"group": "external",
54+
"position": "before"
55+
}
56+
],
57+
"pathGroupsExcludedImportTypes": ["react"],
58+
"newlines-between": "always",
59+
"alphabetize": {
60+
"order": "asc",
61+
"caseInsensitive": true
62+
}
63+
}
64+
]
65+
}
2766
}

Diff for: .prettierrc

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"printWidth": 100,
3-
"semi": false,
4-
"singleQuote": true,
5-
"tabWidth": 4,
6-
"trailingComma": "es5"
2+
"printWidth": 100,
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "all",
7+
"jsxSingleQuote": false
78
}

Diff for: .vscode/settings.json

+28-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
{
2-
"emmet.includeLanguages": {
3-
"javascript": "javascriptreact"
4-
},
5-
"python.pythonPath": "C:\\Users\\jdr2160\\Miniconda3\\envs\\comptox_ai\\python.exe",
6-
"restructuredtext.confPath": "${workspaceFolder}\\docs\\source",
7-
"restructuredtext.languageServer.disabled": true,
2+
"emmet.includeLanguages": {
3+
"javascript": "javascriptreact"
4+
},
5+
"python.pythonPath": "C:\\Users\\jdr2160\\Miniconda3\\envs\\comptox_ai\\python.exe",
6+
"restructuredtext.confPath": "${workspaceFolder}\\docs\\source",
7+
"restructuredtext.languageServer.disabled": true,
88

9-
// Javascript: Prettier
10-
"[javascript]": {
11-
"editor.formatOnSave": true,
12-
"editor.defaultFormatter": "esbenp.prettier-vscode"
13-
},
14-
// Typescript formatter: Prettier
15-
"[typescript]": {
16-
"editor.formatOnSave": true,
17-
"editor.defaultFormatter": "esbenp.prettier-vscode"
18-
},
19-
// Editor indent setting
20-
"editor.tabSize": 4,
21-
"editor.insertSpaces": true,
9+
// Javascript: Prettier
10+
"[javascript]": {
11+
"editor.formatOnSave": true,
12+
"editor.defaultFormatter": "esbenp.prettier-vscode"
13+
},
14+
// Typescript formatter: Prettier
15+
"[typescript]": {
16+
"editor.formatOnSave": true,
17+
"editor.defaultFormatter": "esbenp.prettier-vscode"
18+
},
2219

23-
// Python Docstring formatter: AutoDocstring NumPy
24-
"autoDocstring.docstringFormat": "numpy",
20+
// Python Docstring formatter: AutoDocstring NumPy
21+
"autoDocstring.docstringFormat": "numpy",
2522

26-
// Python formatter: PEP8
27-
"[python]": {
28-
"editor.formatOnSave": true,
29-
"editor.defaultFormatter": "ms-python.autopep8"
30-
},
31-
"python.formatting.provider": "none",
23+
// Python formatter: PEP8
24+
"[python]": {
25+
"editor.formatOnSave": true,
26+
"editor.defaultFormatter": "ms-python.autopep8"
27+
},
28+
"python.formatting.provider": "none",
3229

33-
// Python testing: PyTest
34-
"python.testing.pytestArgs": ["tests"],
35-
"python.testing.unittestEnabled": false,
36-
"python.testing.pytestEnabled": true
30+
// Python testing: PyTest
31+
"python.testing.pytestArgs": ["tests"],
32+
"python.testing.unittestEnabled": false,
33+
"python.testing.pytestEnabled": true
3734
}

0 commit comments

Comments
 (0)