Skip to content

Commit

Permalink
Merge pull request #8191 from blink1073/es-lint
Browse files Browse the repository at this point in the history
Use eslint for TS files
  • Loading branch information
Steven Silvester committed Apr 15, 2020
2 parents cb67ae3 + 4e3e3ae commit f0153e0
Show file tree
Hide file tree
Showing 323 changed files with 2,956 additions and 2,918 deletions.
20 changes: 10 additions & 10 deletions .eslintignore
@@ -1,29 +1,29 @@
node_modules
**/build
**/lib
**/node_modules
**/mock_packages
**/static
**/typings
**/schemas
**/themes
tests/**/coverage
*.map.js
*.bundle.js

dev_mode/index.js
dev_mode/schemas
!dev_mode/static/index.out.js
dev_mode/static
dev_mode/themes
dev_mode/workspaces
docs/_build
docs/api
examples/app/build
examples/app/schemas
examples/app/themes
docs/build
examples/chrome-example-test.js
jupyterlab/chrome-test.js
jupyterlab/geckodriver
jupyterlab/schemas
packages/extensionmanager-extension/examples/listings
jupyterlab/staging/index.js
jupyterlab/staging/yarn.js
jupyterlab/themes
packages/ui-components/src/icon/iconimports.ts
jupyterlab/staging/yarn.js
jupyterlab/staging/index.js

# jetbrains IDE stuff
.idea/
Expand Down
23 changes: 0 additions & 23 deletions .eslintrc

This file was deleted.

51 changes: 51 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,51 @@
module.exports = {
env: {
browser: true,
es6: true,
commonjs: true
},
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:react/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.eslint.json'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
'@typescript-eslint/interface-name-prefix': [
'error',
{ prefixWithI: 'always' }
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/ban-ts-ignore': 'warn',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/triple-slash-reference': 'warn',
'@typescript-eslint/no-inferrable-types': 'off',
'no-inner-declarations': 'off',
'no-prototype-builtins': 'off',
'no-control-regex': 'warn',
'no-undef': 'warn',
'no-case-declarations': 'warn',
'no-useless-escape': 'off',
'prefer-const': 'off'
},
settings: {
react: {
version: 'detect'
}
}
};
22 changes: 11 additions & 11 deletions buildutils/src/add-sibling.ts
@@ -1,4 +1,4 @@
/*-----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
Expand All @@ -20,20 +20,20 @@ import * as utils from './utils';

// Make sure we have required command line arguments.
if (process.argv.length < 3) {
let msg = '** Must supply a target extension';
const msg = '** Must supply a target extension';
process.stderr.write(msg);
process.exit(1);
}

// Extract the desired git repository and repository name.
let target = process.argv[2];
let basePath = path.resolve('.');
const target = process.argv[2];
const basePath = path.resolve('.');
let packageDirName = path.basename(target);

let packagePath = path.resolve(target);
if (fs.existsSync(packagePath)) {
// Copy the package directory contents to the sibling package.
let newPackagePath = path.join(basePath, 'packages', packageDirName);
const newPackagePath = path.join(basePath, 'packages', packageDirName);
fs.copySync(packagePath, newPackagePath);
packagePath = newPackagePath;
} else {
Expand All @@ -52,30 +52,30 @@ if (fs.existsSync(path.join(packagePath, 'node_modules'))) {
}

// Make sure composite is set to true in the new package.
let packageTsconfigPath = path.join(packagePath, 'tsconfig.json');
const packageTsconfigPath = path.join(packagePath, 'tsconfig.json');
if (fs.existsSync(packageTsconfigPath)) {
let packageTsconfig = utils.readJSONFile(packageTsconfigPath);
const packageTsconfig = utils.readJSONFile(packageTsconfigPath);
packageTsconfig.compilerOptions.composite = true;
utils.writeJSONFile(packageTsconfigPath, packageTsconfig);
}

// Get the package.json of the extension.
let pkgJSONPath = path.join(packagePath, 'package.json');
let data = utils.readJSONFile(pkgJSONPath);
const pkgJSONPath = path.join(packagePath, 'package.json');
const data = utils.readJSONFile(pkgJSONPath);
if (data.private !== true) {
data.publishConfig = {};
data.publishConfig.access = 'public';
utils.writeJSONFile(pkgJSONPath, data);
}

// Add the extension path to packages/metapackage/tsconfig.json
let tsconfigPath = path.join(
const tsconfigPath = path.join(
basePath,
'packages',
'metapackage',
'tsconfig.json'
);
let tsconfig = utils.readJSONFile(tsconfigPath);
const tsconfig = utils.readJSONFile(tsconfigPath);
tsconfig.references.push({
path: path.join('..', '..', packageDirName)
});
Expand Down
4 changes: 2 additions & 2 deletions buildutils/src/build.ts
@@ -1,4 +1,4 @@
/*-----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -98,7 +98,7 @@ export namespace Build {
export function ensureAssets(
options: IEnsureOptions
): webpack.Configuration[] {
let { output, packageNames } = options;
const { output, packageNames } = options;

const themeConfig: webpack.Configuration[] = [];

Expand Down
8 changes: 4 additions & 4 deletions buildutils/src/bump-js-major.ts
@@ -1,4 +1,4 @@
/*-----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
Expand All @@ -16,7 +16,7 @@ export function getDeps(
lut: { [key: string]: { [key: string]: string } }
): Set<string> {
const deps: Set<string> = new Set();
for (let name in lut) {
for (const name in lut) {
if ('@jupyterlab/' + pkgName in lut[name]) {
const otherName = name.replace('@jupyterlab/', '');
deps.add(otherName);
Expand Down Expand Up @@ -94,8 +94,8 @@ commander
}

if (options.dryRun) {
console.log('Would run:');
console.log(cmd);
console.debug('Would run:');
console.debug(cmd);
return;
}
utils.run(cmd);
Expand Down
6 changes: 3 additions & 3 deletions buildutils/src/bumpversion.ts
@@ -1,4 +1,4 @@
/*-----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -81,7 +81,7 @@ commander
if (opts.force) {
cmd += ' --yes';
}
let oldVersion = utils.run(
const oldVersion = utils.run(
'git rev-parse HEAD',
{
stdio: 'pipe',
Expand All @@ -100,7 +100,7 @@ commander
utils.run(cmd);
}

let newVersion = utils.run(
const newVersion = utils.run(
'git rev-parse HEAD',
{
stdio: 'pipe',
Expand Down
20 changes: 10 additions & 10 deletions buildutils/src/clean-packages.ts
@@ -1,4 +1,4 @@
/*-----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
Expand All @@ -9,11 +9,11 @@ import * as glob from 'glob';
import { readJSONFile } from './utils';

// Get all of the packages.
let basePath = path.resolve('.');
let baseConfig = readJSONFile(path.join(basePath, 'package.json'));
let packageConfig = baseConfig.workspaces;
let skipSource = process.argv.indexOf('packages') === -1;
let skipExamples = process.argv.indexOf('examples') === -1;
const basePath = path.resolve('.');
const baseConfig = readJSONFile(path.join(basePath, 'package.json'));
const packageConfig = baseConfig.workspaces;
const skipSource = process.argv.indexOf('packages') === -1;
const skipExamples = process.argv.indexOf('examples') === -1;

// Handle the packages
for (let i = 0; i < packageConfig.length; i++) {
Expand All @@ -23,7 +23,7 @@ for (let i = 0; i < packageConfig.length; i++) {
if (skipExamples && packageConfig[i] === 'examples/*') {
continue;
}
let files = glob.sync(path.join(basePath, packageConfig[i]));
const files = glob.sync(path.join(basePath, packageConfig[i]));
for (let j = 0; j < files.length; j++) {
try {
handlePackage(files[j]);
Expand All @@ -38,18 +38,18 @@ for (let i = 0; i < packageConfig.length; i++) {
*/
function handlePackage(packagePath: string): void {
// Read in the package.json.
let packageJSONPath = path.join(packagePath, 'package.json');
const packageJSONPath = path.join(packagePath, 'package.json');
let data: any;
try {
data = require(packageJSONPath);
} catch (e) {
console.log('skipping', packagePath);
console.debug('skipping', packagePath);
return;
}
if (!data.scripts || !data.scripts.clean) {
return;
}
let targets = data.scripts.clean.split('&&');
const targets = data.scripts.clean.split('&&');
for (let i = 0; i < targets.length; i++) {
let target = targets[i].replace('rimraf', '').trim();
target = path.join(packagePath, target);
Expand Down
10 changes: 5 additions & 5 deletions buildutils/src/create-package.ts
@@ -1,4 +1,4 @@
/*-----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
Expand All @@ -8,7 +8,7 @@ import * as inquirer from 'inquirer';
import * as path from 'path';
import * as utils from './utils';

let questions: inquirer.Question[] = [
const questions: inquirer.Question[] = [
{
type: 'input',
name: 'name',
Expand All @@ -23,14 +23,14 @@ let questions: inquirer.Question[] = [

void inquirer.prompt(questions).then(answers => {
let { name, description } = answers;
let dest = path.resolve(path.join('.', 'packages', name));
const dest = path.resolve(path.join('.', 'packages', name));
if (fs.existsSync(dest)) {
console.error('Package already exists: ', name);
process.exit(1);
}
fs.copySync(path.resolve(path.join(__dirname, '..', 'template')), dest);
let jsonPath = path.join(dest, 'package.json');
let data = utils.readJSONFile(jsonPath);
const jsonPath = path.join(dest, 'package.json');
const data = utils.readJSONFile(jsonPath);
if (name.indexOf('@jupyterlab/') === -1) {
name = '@jupyterlab/' + name;
}
Expand Down
12 changes: 6 additions & 6 deletions buildutils/src/create-test-package.ts
@@ -1,4 +1,4 @@
/*-----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
Expand All @@ -10,24 +10,24 @@ import * as utils from './utils';
if (require.main === module) {
// Make sure we have required command line arguments.
if (process.argv.length !== 3) {
let msg = '** Must supply a source package name\n';
const msg = '** Must supply a source package name\n';
process.stderr.write(msg);
process.exit(1);
}
let name = process.argv[2];
let pkgPath = path.resolve(path.join('.', 'packages', name));
const pkgPath = path.resolve(path.join('.', 'packages', name));
if (!fs.existsSync(pkgPath)) {
console.error('Package does not exist: ', name);
process.exit(1);
}
let dest = path.resolve(`./tests/test-${name}`);
const dest = path.resolve(`./tests/test-${name}`);
if (fs.existsSync(dest)) {
console.error('Test package already exists:', dest);
process.exit(1);
}
fs.copySync(path.resolve(path.join(__dirname, '..', 'test-template')), dest);
let jsonPath = path.join(dest, 'package.json');
let data = utils.readJSONFile(jsonPath);
const jsonPath = path.join(dest, 'package.json');
const data = utils.readJSONFile(jsonPath);
if (name.indexOf('@jupyterlab/') === -1) {
name = '@jupyterlab/test-' + name;
}
Expand Down

0 comments on commit f0153e0

Please sign in to comment.