Skip to content

Commit b7e785c

Browse files
authored
Merge pull request #21 from rendertom/eslint-prettier
ESlint and Prettier
2 parents 25faea1 + 04a42bb commit b7e785c

18 files changed

Lines changed: 4640 additions & 507 deletions

.eslintrc.json

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
{
2-
"env": {
3-
"browser": false,
4-
"commonjs": true,
5-
"es6": true,
6-
"node": true
7-
},
8-
"parserOptions": {
9-
"ecmaFeatures": {
10-
"jsx": true
11-
},
12-
"sourceType": "module"
13-
},
14-
"rules": {
15-
"no-const-assign": "warn",
16-
"no-this-before-super": "warn",
17-
"no-undef": "warn",
18-
"no-unreachable": "warn",
19-
"no-unused-vars": "warn",
20-
"constructor-super": "warn",
21-
"valid-typeof": "warn",
22-
"semi": "warn"
23-
}
2+
"env": {
3+
"browser": false,
4+
"commonjs": true,
5+
"es6": true,
6+
"node": true
7+
},
8+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
9+
"parserOptions": {
10+
"ecmaFeatures": {
11+
"jsx": true
12+
},
13+
"sourceType": "module"
14+
},
15+
"rules": {
16+
"no-unreachable": "warn",
17+
"no-unused-vars": "warn",
18+
"semi": "warn",
19+
"valid-typeof": "warn"
20+
}
2421
}

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.node_modules
2+
3+
# Ignore all Markdown files:
4+
*.md

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"endOfLine": "auto",
5+
"printWidth": 100,
6+
"semi": true,
7+
"singleQuote": true,
8+
"tabWidth": 2,
9+
"trailingComma": "es5",
10+
"useTabs": false
11+
}

.vscode/extensions.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
// See http://go.microsoft.com/fwlink/?LinkId=827846
3-
// for the documentation about the extensions.json format
4-
"recommendations": [
5-
"dbaeumer.vscode-eslint"
6-
]
7-
}
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": ["dbaeumer.vscode-eslint"]
5+
}

.vscode/launch.json

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,24 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
6-
"version": "0.2.0",
7-
"configurations": [
8-
{
9-
"name": "Extension",
10-
"type": "extensionHost",
11-
"request": "launch",
12-
"runtimeExecutable": "${execPath}",
13-
"args": [
14-
"--extensionDevelopmentPath=${workspaceFolder}"
15-
]
16-
},
17-
{
18-
"name": "Extension Tests",
19-
"type": "extensionHost",
20-
"request": "launch",
21-
"runtimeExecutable": "${execPath}",
22-
"args": [
23-
"--extensionDevelopmentPath=${workspaceFolder}",
24-
"--extensionTestsPath=${workspaceFolder}/test"
25-
]
26-
}
27-
]
28-
}
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"runtimeExecutable": "${execPath}",
13+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
14+
},
15+
{
16+
"name": "Extension Tests",
17+
"type": "extensionHost",
18+
"request": "launch",
19+
"runtimeExecutable": "${execPath}",
20+
"args": [
21+
"--extensionDevelopmentPath=${workspaceFolder}",
22+
"--extensionTestsPath=${workspaceFolder}/test"
23+
]
24+
}
25+
]
26+
}

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
4-
}
3+
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
4+
}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ All notable changes to the Adobe Script Runner extension will be documented in t
66

77
### Added
88

9-
-
9+
- ESLint + Prettier for a consistent codebase
1010

1111
### Changed
1212

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Adobe Script Runner executes script in the active viewer by default. However, wh
2828
## Installation
2929

3030
- ### From VSCode application
31+
3132
- Open `Extensions` and type `Adobe Script Runner`.
3233
- Click `Install` and then `Reload` button.
3334

@@ -48,7 +49,7 @@ Keyboard shortcut `Cmd+R` is bind to `adobeScriptRunner.ae` command, which will
4849
- Open Keyboard Shortcuts editor and click on the link `keybindings.json`.
4950
- This will open the Default Keyboard Shortcuts on the left and your `keybindings.json` file where you can overwrite the default bindings on the right.
5051
- With `keybindings.json` in focus click `Cmd+K` twice to open an interactive keybinding modal window (or whatever it’s called) and follow the on-screen instructions. This will create a new binding entry in the `keybindings.json` file.
51-
- Edit the `command` property to `adobeScriptRunner.XX`, where XX is an abbreviation of the application. Check available abbreviations in `Extensions > Adobe Script Runner > Contributions` tab.
52+
- Edit the `command` property to `adobeScriptRunner.XX`, where XX is an abbreviation of the application. Check available abbreviations in `Extensions > Adobe Script Runner > Contributions` tab.
5253

5354
The result should look something like this:
5455

@@ -108,4 +109,4 @@ Executable paths for InCopy and InDesign for Windows are not exposed because the
108109

109110
## Known issues
110111

111-
- The host application does not get focus on script run.
112+
- The host application does not get focus on script run.

lib/buildCommand.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ const ide = require('./ide.js');
88
* @param {Object} hostApp entry from hostApps[hostApp].
99
*/
1010
function buildCommand(hostApp) {
11-
try {
12-
getScriptFile(function(scriptFile) {
13-
getShellCommand(hostApp, scriptFile, function(command) {
14-
console.log('Running shell command:', command);
15-
cp.exec(command, (error, stdout, stderr) => {
16-
if (error) {
17-
console.error(`exec error: ${error}`);
18-
return;
19-
}
11+
try {
12+
getScriptFile(function (scriptFile) {
13+
getShellCommand(hostApp, scriptFile, function (command) {
14+
console.log('Running shell command:', command);
15+
cp.exec(command, (error, stdout, stderr) => {
16+
if (error) {
17+
console.error(`exec error: ${error}`);
18+
return;
19+
}
2020

21-
console.log(stdout);
22-
console.log(stderr);
23-
});
24-
ide.showInformationMessage(`Script sent to ${hostApp.appName}`);
25-
});
26-
});
27-
} catch (error) {
28-
if (typeof error !== 'undefined') {
29-
console.log(error);
30-
}
31-
}
21+
console.log(stdout);
22+
console.log(stderr);
23+
});
24+
ide.showInformationMessage(`Script sent to ${hostApp.appName}`);
25+
});
26+
});
27+
} catch (error) {
28+
if (typeof error !== 'undefined') {
29+
console.log(error);
30+
}
31+
}
3232
}
3333

34-
module.exports = buildCommand;
34+
module.exports = buildCommand;

lib/extension.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ const vscode = require('vscode');
55
/**
66
* @description Method is called when extension is activated.
77
* Extension is activated the very first time the command is executed.
8-
* @param {any} context vscode.ExtensionContext
98
*/
10-
function activate(context) {
11-
hostApps.forEach(hostApp => {
12-
vscode.commands.registerCommand(
13-
`adobeScriptRunner.${hostApp.shortName}`,
14-
() => buildCommand(hostApp)
15-
);
16-
});
9+
function activate() {
10+
hostApps.forEach((hostApp) => {
11+
vscode.commands.registerCommand(`adobeScriptRunner.${hostApp.shortName}`, () =>
12+
buildCommand(hostApp)
13+
);
14+
});
1715
}
1816

1917
exports.activate = activate;

0 commit comments

Comments
 (0)