-
-
Notifications
You must be signed in to change notification settings - Fork 92
Add pre-commit #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pre-commit #637
Changes from all commits
8f4c931
c9a234b
4a400c2
aef8148
cf46fb9
6f752db
db2c48b
70627f4
d0ccaf7
73d776d
843e72f
f471437
a129e30
3d2a717
dcc3f5c
c3f6c27
1632849
37272b2
d744b35
ed295a0
ec530db
6f5c36a
154d08b
d958e09
32a0e64
03bd12d
0e525eb
1308ce7
316b873
cb30dcb
696ce82
b726555
aaf428a
61ffb5d
8b4abd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # See https://EditorConfig.org | ||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| indent_size = 2 | ||
| indent_style = space | ||
| max_line_length = 80 | ||
| trim_trailing_whitespace = true | ||
|
|
||
| [*.json] | ||
| indent_style = tab | ||
|
|
||
| [*.py] | ||
| indent_style = space | ||
| indent_size = 4 | ||
|
|
||
| [*.{yml,yaml}] | ||
| # Trailing whitespace breaks yaml files if you use a multiline string | ||
| # with a line that has trailing white space. Many of our recorded | ||
| # tests use strings with trailing white space to represent the final | ||
| # document contents. For example | ||
| # src/test/suite/fixtures/recorded/languages/ruby/changeCondition.yml | ||
| trim_trailing_whitespace = false | ||
|
|
||
| [Makefile] | ||
| indent_style = tab | ||
|
|
||
| [src/vendor/**] | ||
| charset = unset | ||
| end_of_line = unset | ||
| indent_size = unset | ||
| indent_style = unset | ||
| trim_trailing_whitespace = unset | ||
| insert_final_newline = unset | ||
| max_line_length = unset |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| minimum_pre_commit_version: "2.9.0" | ||
pokey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ci: | ||
| autofix_prs: false | ||
| exclude: ^src/vendor/ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be a good idea to move pre-commit-hooks before shed? They should be faster I think; failing fast would probably be ideal.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Fwiw, though, pre-commit doesn't short-circuit, so I'm not sure there's too much benefit
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, I suppose you want to run black after flynt anyway
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah exactly. And as a matter of fact I did find it useful to be able to hit Ctrl-c when running locally if I noticed failure, so I guess there is some benefit 👍. Thanks for all the helpful comments! I'm happy with how it turned out |
||
| rev: v4.1.0 | ||
| hooks: | ||
| - id: check-added-large-files | ||
| - id: check-case-conflict | ||
| - id: check-executables-have-shebangs | ||
| - id: check-merge-conflict | ||
| - id: check-shebang-scripts-are-executable | ||
| - id: check-symlinks | ||
pokey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - id: destroyed-symlinks | ||
| - id: detect-private-key | ||
| - id: end-of-file-fixer | ||
| - id: fix-byte-order-marker | ||
| - id: mixed-line-ending | ||
| - id: trailing-whitespace | ||
| # Trailing whitespace breaks yaml files if you use a multiline string | ||
| # with a line that has trailing white space. Many of our recorded | ||
| # tests use strings with trailing white space to represent the final | ||
| # document contents. For example | ||
| # src/test/suite/fixtures/recorded/languages/ruby/changeCondition.yml | ||
| exclude: ^src/test/suite/fixtures/recorded/.*/[^/]*\.yml$ | ||
| - repo: https://github.com/pre-commit/mirrors-prettier | ||
| rev: "v2.6.2" | ||
| hooks: | ||
| - id: prettier | ||
pokey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - repo: https://github.com/ikamensh/flynt/ | ||
| rev: "0.76" | ||
| hooks: | ||
| - id: flynt | ||
| - repo: https://github.com/Zac-HD/shed | ||
| rev: 0.9.5 | ||
| hooks: | ||
| - id: shed | ||
| # TODO: bump to --py310-plus when Talon moves to Python 3.10. | ||
| args: [--refactor, --py39-plus] | ||
| types_or: [python, markdown, rst] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /src/vendor | ||
|
|
||
| # We use our own format for our recorded yaml tests to keep them compact | ||
| /src/test/suite/fixtures/recorded/**/*.yml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
| // for the documentation about the extensions.json format | ||
| "recommendations": [ | ||
| "dbaeumer.vscode-eslint" | ||
| "dbaeumer.vscode-eslint", | ||
| "esbenp.prettier-vscode" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will probably be nice for new contributors |
||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,8 @@ | |
| "search.exclude": { | ||
| "out": true // set this to false to include "out" folder in search results | ||
| }, | ||
| "[typescript]": { | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode" | ||
| }, | ||
| "python.formatting.provider": "black", | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that we now use prettier for all file types that it supports
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you confirmed that it's not trying to use prettier for python for example. "that it supports" it's not something I would rely on to work automatically.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I just tried saving and it seems to be using black |
||
| // Turn off tsc task auto detection since we have the necessary tasks as npm scripts | ||
| "typescript.tsc.autoDetect": "off", | ||
| "cSpell.words": [ | ||
|
|
@@ -21,4 +20,4 @@ | |
| "pojo", | ||
| "subword" | ||
| ] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -513,15 +513,17 @@ | |
| "@types/semver": "^7.3.9", | ||
| "@types/sinon": "^10.0.2", | ||
| "@types/vscode": "^1.61.0", | ||
| "@typescript-eslint/eslint-plugin": "^5.11.0", | ||
| "@typescript-eslint/parser": "^5.11.0", | ||
| "@typescript-eslint/eslint-plugin": "^5.20.0", | ||
| "@typescript-eslint/parser": "^5.20.0", | ||
| "esbuild": "^0.11.12", | ||
| "eslint": "^7.15.0", | ||
| "eslint": "^8.13.0", | ||
| "eslint-config-prettier": "^8.5.0", | ||
| "fast-xml-parser": "^3.20.0", | ||
| "glob": "^7.1.7", | ||
| "js-yaml": "^4.1.0", | ||
| "mocha": "^8.1.3", | ||
| "npm-license-crawler": "^0.2.1", | ||
| "prettier": "2.6.2", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big thing but if you want to add the ability to shift up rather have a strict peg, that would be nice.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense to pin
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm it's a bit of a bummer to have to specify prettier version in two places. I wonder if that's avoidable? 🤔
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I've now pinned everything in package.json that's specified in the pre-commit config, but that seems not great. I wonder if there's a better way
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll open an issue on their repo and see what comes of it. I think that duplicating it is the path forward for now.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is the resolution. The tldr; is to rely on a repository local hookand throw the check into an npm or yarn script.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, given that currently I think it's ok to leave Sound good? |
||
| "semver": "^7.3.5", | ||
| "sinon": "^11.1.1", | ||
| "typescript": "^4.5.5", | ||
|
|
@@ -532,4 +534,4 @@ | |
| "immutability-helper": "^3.1.1", | ||
| "lodash": "^4.17.21" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,7 @@ export function getSelectionInfo( | |
| */ | ||
| export function selectionsToSelectionInfos( | ||
| document: TextDocument, | ||
| selectionMatrix: Selection[][], | ||
| selectionMatrix: (readonly Selection[])[], | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like our typescript version got bumped when I bumped yarn.lock, so now we need to be stricter about |
||
| rangeBehavior: DecorationRangeBehavior = DecorationRangeBehavior.ClosedClosed | ||
| ): FullSelectionInfo[][] { | ||
| return selectionMatrix.map((selections) => | ||
|
|
@@ -118,7 +118,7 @@ export async function callFunctionAndUpdateSelections( | |
| rangeUpdater: RangeUpdater, | ||
| func: () => Thenable<unknown>, | ||
| document: TextDocument, | ||
| selectionMatrix: Selection[][] | ||
| selectionMatrix: (readonly Selection[])[] | ||
| ): Promise<Selection[][]> { | ||
| const selectionInfoMatrix = selectionsToSelectionInfos( | ||
| document, | ||
|
|
@@ -173,7 +173,7 @@ export async function performEditsAndUpdateSelections( | |
| rangeUpdater: RangeUpdater, | ||
| editor: TextEditor, | ||
| edits: Edit[], | ||
| originalSelections: Selection[][] | ||
| originalSelections: (readonly Selection[])[] | ||
| ) { | ||
| const document = editor.document; | ||
| const selectionInfoMatrix = selectionsToSelectionInfos( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,15 +20,17 @@ export function addDecorationsToEditors( | |
| ) { | ||
| hatTokenMap.clear(); | ||
|
|
||
| var editors: vscode.TextEditor[]; | ||
| var editors: readonly vscode.TextEditor[]; | ||
|
|
||
| if (vscode.window.activeTextEditor == null) { | ||
| editors = vscode.window.visibleTextEditors; | ||
| } else { | ||
| editors = vscode.window.visibleTextEditors.filter( | ||
| (editor) => editor !== vscode.window.activeTextEditor | ||
| ); | ||
| editors.unshift(vscode.window.activeTextEditor); | ||
| editors = [ | ||
| vscode.window.activeTextEditor, | ||
| ...vscode.window.visibleTextEditors.filter( | ||
| (editor) => editor !== vscode.window.activeTextEditor | ||
| ), | ||
| ]; | ||
|
Comment on lines
-31
to
+33
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't use |
||
| } | ||
|
|
||
| const tokens = concat( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| "module name","licenses","repository","licenseUrl","parents" | ||
| "@docusaurus/core@2.0.0-beta.15","MIT","https://github.com/facebook/docusaurus","https://github.com/facebook/docusaurus/raw/master/LICENSE","website" | ||
| "@docusaurus/preset-classic@2.0.0-beta.15","MIT","https://github.com/facebook/docusaurus","https://github.com/facebook/docusaurus/raw/master/LICENSE","website" | ||
| "@docusaurus/core@2.0.0-beta.17","MIT","https://github.com/facebook/docusaurus","https://github.com/facebook/docusaurus/raw/master/LICENSE","website" | ||
| "@docusaurus/preset-classic@2.0.0-beta.17","MIT","https://github.com/facebook/docusaurus","https://github.com/facebook/docusaurus/raw/master/LICENSE","website" | ||
| "@mdx-js/react@1.6.22","MIT","https://github.com/mdx-js/mdx","https://github.com/mdx-js/mdx/raw/master/license","website" | ||
| "@types/lodash@4.14.168","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped","https://github.com/DefinitelyTyped/DefinitelyTyped/raw/master/LICENSE","cursorless" | ||
| "@types/lodash@4.14.181","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped","https://github.com/DefinitelyTyped/DefinitelyTyped/raw/master/LICENSE","cursorless" | ||
| "clsx@1.1.1","MIT","https://github.com/lukeed/clsx","https://github.com/lukeed/clsx/raw/master/license","website" | ||
| "immutability-helper@3.1.1","MIT","https://github.com/kolodny/immutability-helper","https://github.com/kolodny/immutability-helper/raw/master/LICENSE","cursorless" | ||
| "mdast-util-find-and-replace@2.1.0","MIT","https://github.com/syntax-tree/mdast-util-find-and-replace","https://github.com/syntax-tree/mdast-util-find-and-replace/raw/master/license","website" | ||
| "prism-react-renderer@1.2.1","MIT","https://github.com/FormidableLabs/prism-react-renderer","https://github.com/FormidableLabs/prism-react-renderer/raw/master/LICENSE","website" | ||
| "prism-react-renderer@1.3.1","MIT","https://github.com/FormidableLabs/prism-react-renderer","https://github.com/FormidableLabs/prism-react-renderer/raw/master/LICENSE","website" | ||
| "react-dom@17.0.2","MIT","https://github.com/facebook/react","https://github.com/facebook/react/raw/master/LICENSE","website" | ||
| "react@17.0.2","MIT","https://github.com/facebook/react","https://github.com/facebook/react/raw/master/LICENSE","website" | ||
| "unist-util-visit@4.1.0","MIT","https://github.com/syntax-tree/unist-util-visit","https://github.com/syntax-tree/unist-util-visit/raw/master/license","website" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let prettier handle all the formatting; eslint just checks for / fixes problems