Skip to content

Commit

Permalink
(maint) Set syntax and format style guidelines
Browse files Browse the repository at this point in the history
Update eslint and prettier packages and add style and format guidelines to editorconfig and VS Code worskpace settings file.

This aligns to company standards for code style and formatting and ensures consistent spacing, line endings, and file encodings. This does not enable any new eslint rules, as that is out of scope for this line of work.

This also configures VS Code to use prettier and eslint for all typescript, javascript and json formatting and use eslint and prettier to enforce guidelines.
  • Loading branch information
jpogran committed Aug 27, 2021
1 parent 59f6cd4 commit 790129a
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 12 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
out
out
src/test
testFixture
9 changes: 5 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"env": { "browser": true, "es6": true, "node": true },
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
]
}
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* text=auto
* text eol=lf
# special shasum test can't have linefeeds change
# https://github.com/actions/checkout/issues/226
shasumtest.txt text eol=lf
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
snippets
syntaxes
out
package-lock.json
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"endOfLine": "lf",
"printWidth": 120,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
]
}
46 changes: 43 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
{
"editor.insertSpaces": false,
"typescript.preferences.quoteStyle": "single",
"typescript.tsc.autoDetect": "off"
"editor.insertSpaces": true,
"editor.tabSize": 2,

"files.encoding": "utf8",
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,

"files.exclude": {
"node_modules": true,
"out": true
},
"search.exclude": {
"node_modules": true,
"out": true
},

"typescript.format.enable": false,
"typescript.tsc.autoDetect": "off",

"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.wordWrapColumn": 80,
"editor.wordWrap": "wordWrapColumn",
"editor.quickSuggestions": false,
"files.trimTrailingWhitespace": false
},
"[typescript]": {
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
105 changes: 104 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
"package": "vsce package",
"compile": "tsc -b",
"watch": "tsc -b -w",
"lint": "eslint .",
"lint": "eslint src/**/*.ts",
"test-compile": "tsc -p ./",
"test": "npm run test-compile && node ./out/test/runTest.js"
},
Expand All @@ -245,9 +245,12 @@
"@types/yauzl": "^2.9.1",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"eslint": "^7.6.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"glob": "^7.1.6",
"mocha": "^8.2.1",
"prettier": "^2.3.2",
"typescript": "^3.9.7",
"vsce": "^1.93.0",
"vscode-test": "^1.5.2"
Expand Down

0 comments on commit 790129a

Please sign in to comment.