Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Workiva/fedx
18 changes: 18 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2

updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
gha:
patterns: ["*"]

- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
npm:
patterns: ["*"]
53 changes: 7 additions & 46 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,57 +22,18 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 17
- name: install dependencies
run: |
yarn install
node-version: 22

- name: Compile
run: yarn compile

- name: Lint
run: yarn lint

- name: What is the OS
run: cat /etc/*-release

# Tests if using Linux
- name: install xvfb
run: sudo apt-get update && sudo apt-get install -y xvfb
if: runner.os == 'Linux'

- name: Run Tests and Generate XML Report
run: xvfb-run -a yarn test
if: runner.os == 'Linux'

# Tests if not using Linux
- name: Non-Linux Tests
run: yarn test
if: runner.os != 'Linux'

- name: Debug Path
run: ls -R out

- name: Upload XML Test Report
uses: actions/upload-artifact@v4
with:
name: test-reports
path: out/test

- name: Upload Test Artifacts
uses: actions/upload-artifact@v4
- uses: pnpm/action-setup@v4
with:
name: Artifacts
path: artifacts/file.txt
version: 10
- run: pnpm install

# Generate vsix file and upload the artifact
- name: generate .vsix file
run: yarn package
run: npx @vscode/vsce package --no-dependencies

- name: Upload .vsix Artifact
uses: actions/upload-artifact@v4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
.vscode-test
node_modules
out
dist

*.vsix
31 changes: 2 additions & 29 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
// Copyright 2020 Workiva Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
Expand All @@ -21,28 +9,13 @@
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
11 changes: 11 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.github/**
.vscode/**
.vscode-test/**

src/**
node_modules/**

.gitignore
**/tsconfig.json
**/.eslintrc.json
**/*.ts
41 changes: 13 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,20 @@ This is a VS Code extension that enables format on save for Dart projects. Ultim

## Setting up the extension
1. __Install the extension:__ The extension is installed via the `.vsix` file. In this package, there is a `over-react-format-on-save-x.x.x.vsix` file. Download that file locally, and follow [these instructions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension#packaging-extensions) to install it.
1. __Enable the formatter:__ Open the Command Palette (__⌘ + ⇧ + P__ by default) and search for `OverReact Format on Save: Enable`. This will allow the formatter to be run, and can be disabled by using the `OverReact Format on Save: Disable` command.
1. You're good to go!

## Extension Configuration Options
Configuration options can be set by:
1. Go to VS Code's settings (__⌘ + ,__ by default).
1. Navigate to the Extension settings, using the menu on the left of the settings window.
1. In the dropdown for "Extensions", find "OverReact Format..." and click on it.
1. Interacting with the specific configuration option..
2. __Enable the formatter:__ Open settings (__⌘ + ,__) and add the following:

```js
// disable the formatter that comes from dart-code
"dart.enableSdkFormatter": false,

## Enabling Line-Length Detection
__Default: enabled__
"[dart]": {
// specify the default formatter as this extension
"editor.defaultFormatter": "workiva.overReactFormatOnSave",

If OverReact Format is being used, this extension has the capability to pull a line-length from the standard `dart_dev/config.dart` file used to configure Workiva's DartDev tool. This is enabled by default, but will only have an effect if the project is using OverReact Format.
// optionally enable "formatOnSave" functionality
"editor.formatOnSave": true
},
```

## Setting a Custom Line-Length
__Default: 0 (disabled)__

In the case you need to run the format command with a custom line-length, but the `Detect Custom Line Length` is not viable, it is possible to set a line-length through the extension using the "Custom Line Length" setting.

__NOTE:__ Both this and `Detect Custom Line Length` cannot be set at the same time. If `Custom Line Length` is greater than `0`, it is considered set. If both are set, `Custom Line Length` will take precendence and auto detection will be skipped.

## Scan for Nested Packages
__Default: disabled__

Allows the extension to scan for pubspec.yaml files that are nested somewhere in the project (defaulting to the project root) when the formatter runs.

The scanning occurs along the targeted file path and therefore will not detect a pubspec file that is not within a parent directory of the file getting formatted. Because the extension will run in the context of what is determined the Dart package, it will only use the pubspec from that package. This impacts the OverReact Format executable version. By default, this extension always assumes that the content root (usually the project root) is the root of the Dart package.

Enabling this is desirable when the project root (or the content root) has no pubspec (and there's one nested in the project) or there is a nested dart_dev config file (with its own pubspec). Enabling this is likely undesirable if your dart_dev config is in the project root or you do not have nested packages. When this is enabled, it assumes that a nested package has it's own `dart_dev` configuration file and will scan for the `tool` directory relative to the detected nested pubspec.

**Enjoy!**
3. You're good to go!
Binary file removed over-react-format-on-save-1.0.2.vsix
Binary file not shown.
80 changes: 9 additions & 71 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,21 @@
"publisher": "Workiva",
"repository": "https://github.com/Workiva/vs-code-format-on-save/",
"engines": {
"vscode": "^1.44.0"
"vscode": "^1.97.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onLanguage:dart"
],
"categories": ["Other"],
"activationEvents": ["onLanguage:dart"],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "overReactFormatOnSave.enableOverReactFormatOnSave",
"title": "OverReact Format On Save: Enable"
},
{
"command": "overReactFormatOnSave.disableOverReactFormatOnSave",
"title": "OverReact Format On Save: Disable"
}
],
"configuration": {
"title": "OverReact Format On Save",
"type": "object",
"properties": {
"overReact.formatOnSave.customLineLength": {
"Title": "Custom Line-Length",
"type": "number",
"description": "The line-length the formatter should use. Note that both this and `Detect Custom Line-Length` cannot be set at the same time. If this is set (i.e. greater than 0) and `Detect Custom Line-Length` is `true`, this property will take precedence.",
"minimum": 0
},
"overReact.formatOnSave.detectCustomLineLength": {
"Title": "Detect Custom Line-Length",
"type": "boolean",
"description": "Attempt to autodetect custom line-length. If you are using Dart Dev have a `tool/dart_dev/config.dart` file with a custom line-length defined, you can set this to true to use that line-length.",
"default": true
},
"overReact.formatOnSave.scanForNestedProjects": {
"Title": "Scan for Nested Packages",
"type": "boolean",
"description": "Allows the extension to scan for pubspec.yaml files that are nested somewhere in the project (defaulting to the project root) when the formatter runs.\n\nSee the extension details for more information.",
"default": false
},
"overReact.formatOnSave.showOutputOnError": {
"Title": "Show output console when error occurs in formatter",
"type": "boolean",
"description": "By default the extension will show the output console when an error occurs in the formatter. This can be disabled.",
"default": true
}
}
}
},
"scripts": {
"vscode:prepublish": "npm run compile",
"vscode:prepublish": "pnpm run compile",
"compile": "tsc -p ./",
"lint": "eslint src --ext ts",
"watch": "tsc -watch -p ./",
"test": "node ./out/test/run_tests.js",
"package": "vsce package -o ./vs-code-format-on-save.vsix"
"watch": "tsc -watch -p ./"
},
"icon": "images/OverReact_Logo.png",
"devDependencies": {
"@types/glob": "^7.1.1",
"@types/mocha": "^7.0.2",
"@types/node": "^13.11.0",
"@types/vscode": "^1.44.0",
"@typescript-eslint/eslint-plugin": "^3.1.0",
"@typescript-eslint/parser": "^3.1.0",
"eslint": "^6.8.0",
"glob": "^7.1.6",
"mocha": "^7.1.1",
"typescript": "^3.8.3",
"vscode-test": "^1.3.0",
"@vscode/vsce": "^2.19.0"
},
"dependencies": {
"@types/semver": "^7.2.0",
"semver": "^7.5.2",
"yaml": "^1.10.0"
"@types/node": "20.x",
"@types/vscode": "^1.97.0",
"typescript": "^5.7.3",
"esbuild": "^0.24.2"
}
}
Loading