Skip to content

Commit

Permalink
refactor: apply linting
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Dec 11, 2019
1 parent 0df1a5a commit 37e1d7b
Show file tree
Hide file tree
Showing 220 changed files with 2,307 additions and 1,180 deletions.
11 changes: 6 additions & 5 deletions .ci/common-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ steps:
env:
DISPLAY: ':99.0'

- task: Gulp@0
displayName: gulp lint
inputs:
targets: lint
condition: and(eq(${{ parameters.runTests }}, true), eq(variables['Agent.OS'], 'Darwin'))

- task: PublishTestResults@2
displayName: Publish Tests Results
inputs:
testResultsFiles: '*-results.xml'
searchFolder: '$(Build.ArtifactStagingDirectory)/test-results'
condition: and(succeededOrFailed(), eq(${{ parameters.runTests }}, true))

- task: Gulp@0
displayName: gulp lint
inputs:
targets: lint
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
ignorePatterns: ['**/*.d.ts', 'src/int-chrome/**/*.ts', 'src/test/**/*.ts'],
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
plugins: ['header'],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
},
rules: {
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': ['error', { prefixWithI: 'always' }],
'header/header': [
'error',
'block',
'---------------------------------------------------------\n * Copyright (C) Microsoft Corporation. All rights reserved.\n *--------------------------------------------------------',
],
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
},
};
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"activityBar.background": "#105200"
},
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript"
],
"search.exclude": {
"**/testdata": true,
"**/testWorkspace": true
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Or alternatively by self-hosting:

1. Clone this repository and run `npm install`,
2. Then either:
- Run `gulp build --nightly` to package a `.vsix` you can install manually, or
- Run `npm run compile`, then open the repository in VS Code and select "Run Extension"
- Run `gulp build --nightly` to package a `.vsix` you can install manually, or
- Run `npm run compile`, then open the repository in VS Code and select "Run Extension"
3. Then you should be able to run and debug your programs without changing your launch config. If you can't, then please file an issue.

## Features
Expand All @@ -30,8 +30,7 @@ Or alternatively by self-hosting:

<img width="273" alt="Screen Shot 2019-07-30 at 4 16 15 PM" src="https://user-images.githubusercontent.com/883973/62171895-67308a00-b2e5-11e9-832a-0867cf2ea411.png">


- Full stack debugging with all targets at a glance.
* Full stack debugging with all targets at a glance.

<img width="320" alt="Screen Shot 2019-07-30 at 4 13 21 PM" src="https://user-images.githubusercontent.com/883973/62171782-03a65c80-b2e5-11e9-958b-73582efd513c.png">

Expand Down Expand Up @@ -64,6 +63,7 @@ Or alternatively by self-hosting:
<img width="751" alt="Screen Shot 2019-07-24 at 10 29 43 PM" src="https://user-images.githubusercontent.com/883973/61848317-8e5d0680-ae62-11e9-88db-5017ed58a430.png">

- Complete command line API:

- `inspect(function)` - reveal function definition
- `copy(value)` - copies value into clipboard
- `queryObjects(prototype)` - returns all heap objects of type
Expand All @@ -81,14 +81,15 @@ Or alternatively by self-hosting:
- Pretty print minified source with complete debugging support

<!--img width="464" alt="Screen Shot 2019-07-22 at 9 55 22 PM" src="https://user-images.githubusercontent.com/883973/61683714-6c7d4b80-accb-11e9-92ae-084e3b4f36e7.png"-->
![pretty_print](https://user-images.githubusercontent.com/883973/61990381-71f0d380-aff4-11e9-95ae-10f2b1a732ec.gif)

![pretty_print](https://user-images.githubusercontent.com/883973/61990381-71f0d380-aff4-11e9-95ae-10f2b1a732ec.gif)


<img width="553" alt="Screen Shot 2019-07-22 at 9 56 12 PM" src="https://user-images.githubusercontent.com/883973/61683776-a9e1d900-accb-11e9-9884-f7494b1d8fc4.png">

- Step into async, step into Worker, etc

![step_into](https://user-images.githubusercontent.com/883973/61990326-2c7fd680-aff3-11e9-9602-ba4b25c7f138.gif)
![step_into](https://user-images.githubusercontent.com/883973/61990326-2c7fd680-aff3-11e9-9602-ba4b25c7f138.gif)

- All locations go through source maps: stack trace on pause, console methods, exceptions, function locations
- Breakpoints set in source maps are guranteed to be resolved in time (in newer V8 versions).
Expand Down
58 changes: 29 additions & 29 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

const del = require('del');
const filter = require('gulp-filter');
Expand All @@ -12,7 +13,6 @@ const sourcemaps = require('gulp-sourcemaps');
const ts = require('gulp-typescript');
const rename = require('gulp-rename');
const merge = require('merge2');
const tslint = require('gulp-tslint');
const prettier = require('gulp-prettier');
const typescript = require('typescript');
const vsce = require('vsce');
Expand All @@ -27,7 +27,6 @@ const translationProjectName = 'vscode-extensions';
const translationExtensionName = 'js-debug';

const sources = ['src/**/*.ts'];
const tslintFilter = ['**', '!**/*.d.ts'];
const allPackages = [];

const buildDir = 'out';
Expand Down Expand Up @@ -85,10 +84,6 @@ async function readJson(file) {

const replaceNamespace = () => replace(/NAMESPACE\((.*?)\)/g, `${namespace}$1`);
const tsProject = ts.createProject('./tsconfig.json', { typescript });
const tslintOptions = {
formatter: 'prose',
rulesDirectory: 'node_modules/tslint-microsoft-contrib',
};
const prettierOptions = require('./package.json').prettier;

gulp.task('clean', () =>
Expand Down Expand Up @@ -309,28 +304,33 @@ gulp.task(
),
);

gulp.task('format', () => {
const f = filter(tslintFilter, { restore: true });

return gulp
.src(sources)
.pipe(prettier(prettierOptions))
.pipe(f)
.pipe(tslint({ ...tslintOptions, fix: true }))
.pipe(tslint.report({ emitError: false }))
.pipe(f.restore)
.pipe(gulp.dest('./src'));
});
const runPrettier = (fix, callback) => {
const child = cp.fork(
'./node_modules/prettier/bin-prettier.js',
[fix ? '--write' : '--list-different', 'src/**/*.ts', '!src/**/*.d.ts', '*.md'],
{ stdio: 'inherit' },
);

gulp.task('lint', () =>
gulp
.src(sources)
.pipe(prettier.check(prettierOptions))
.pipe(filter(tslintFilter))
.pipe(tslint(tslintOptions))
.pipe(tslint.report())
.pipe(gulp.dest('./src')),
);
child.on('exit', code => (code ? callback(`Prettier exited with code ${code}`) : callback()));
};

const runEslint = (fix, callback) => {
const child = cp.fork(
'./node_modules/eslint/bin/eslint.js',
['--color', 'src/**/*.ts', fix ? '--fix' : ''],
{ stdio: 'inherit' },
);

child.on('exit', code => (code ? callback(`Eslint exited with code ${code}`) : callback()));
}

gulp.task('format:prettier', callback => runPrettier(true, callback));
gulp.task('format:eslint', callback => runEslint(true, callback));
gulp.task('format', gulp.series('format:prettier', 'format:eslint'));

gulp.task('lint:prettier', callback => runPrettier(false, callback));
gulp.task('lint:eslint', callback => runEslint(false, callback));
gulp.task('lint', gulp.parallel('lint:prettier', 'lint:eslint'));

/**
* Run a command in the terminal using exec, and wrap it in a promise
Expand Down
Loading

0 comments on commit 37e1d7b

Please sign in to comment.