Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1061658

Browse files
authored
Merge pull request #151 from mads-hartmann/eslint-setup
Switch from TSLint (deprecated) to ESLint
2 parents 2488754 + 4a42ab4 commit 1061658

File tree

22 files changed

+1856
-1589
lines changed

22 files changed

+1856
-1589
lines changed

‎.eslintignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/out
2+
**/node_modules
3+
!.eslintrc.js

‎.eslintrc.js‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
plugins: ['@typescript-eslint', 'jest', 'simple-import-sort', 'prettier'],
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'prettier',
8+
'prettier/@typescript-eslint',
9+
],
10+
parserOptions: {
11+
ecmaFeatures: {
12+
jsx: true,
13+
},
14+
ecmaVersion: 2018,
15+
sourceType: 'module',
16+
project: './server/tsconfig.json',
17+
},
18+
rules: {
19+
'prettier/prettier': [
20+
'error',
21+
{
22+
trailingComma: 'all',
23+
singleQuote: true,
24+
printWidth: 90,
25+
semi: false,
26+
},
27+
],
28+
'@typescript-eslint/no-unused-vars': [
29+
'error',
30+
{
31+
vars: 'all',
32+
args: 'none',
33+
argsIgnorePattern: '^_',
34+
ignoreRestSiblings: true,
35+
},
36+
],
37+
'no-console': [
38+
'error',
39+
{
40+
allow: ['warn', 'error'],
41+
},
42+
],
43+
'prefer-destructuring': [
44+
'error',
45+
{
46+
array: false,
47+
object: true,
48+
},
49+
],
50+
'prefer-const': 'error',
51+
'prefer-template': 'error',
52+
'simple-import-sort/sort': 'error',
53+
54+
'@typescript-eslint/explicit-function-return-type': 'off',
55+
'@typescript-eslint/explicit-member-accessibility': 'off',
56+
'@typescript-eslint/no-explicit-any': 'off',
57+
'@typescript-eslint/no-use-before-define': 'off',
58+
'@typescript-eslint/prefer-interface': 'off',
59+
'@typescript-eslint/no-var-requires': 'off',
60+
'no-unused-vars': 'off', // replaced by @typescript-eslint/no-unused-vars
61+
},
62+
env: {
63+
browser: false,
64+
node: true,
65+
es6: true,
66+
'jest/globals': true,
67+
},
68+
}

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ server/out
55
.DS_Store
66
*.log
77
coverage
8+
.eslintcache

‎.vscode/settings.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"search.exclude": {
77
"out": true
88
},
9-
"tslint.autoFixOnSave": true,
9+
"eslint.autoFixOnSave": true,
1010
"typescript.tsdk": "./node_modules/typescript/lib",
1111
"typescript.tsc.autoDetect": "off"
1212
}

‎docs/development-guide.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ below.
4343

4444
## Development Tools
4545

46-
To support a good develop workflow we set up [TSLint][tslint], [Prettier][prettier] and integration tests using [Jest][jest]:
46+
To support a good develop workflow we set up [eslint][eslint], [Prettier][prettier] and integration tests using [Jest][jest]:
4747

4848
yarn run check # (runs lint, prettier and tests)
4949
yarn run lint
@@ -81,6 +81,6 @@ I'm open to suggestions on how to improve this workflow.
8181
[ide-bash]: https://github.com/mads-hartmann/ide-bash
8282
[jest]: https://facebook.github.io/jest/
8383
[prettier]: https://prettier.io/
84-
[tslint]: https://palantir.github.io/tslint/
84+
[eslint]: https://eslint.org/
8585
[yarn]: https://yarnpkg.com/lang/en/docs/install/
8686
[node]: https://nodejs.org/en/download/

‎package.json‎

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,29 @@
66
"compile": "yarn run compile:server && yarn run compile:client",
77
"compile:client": "cd vscode-client && yarn run compile",
88
"compile:server": "cd server && yarn run compile",
9-
"lint": "tslint --project vscode-client --fix && tslint --project server --fix",
10-
"lint:bail": "tslint --project vscode-client && tslint --project server",
11-
"test": "jest --runInBand --forceExit",
12-
"test:coverage": "yarn run test -- --coverage",
13-
"test:watch": "yarn run test -- --watch",
9+
"lint": "yarn lint:bail --fix",
10+
"lint:bail": "eslint . --ext js,ts,tsx --cache",
11+
"test": "jest --runInBand",
12+
"test:coverage": "yarn run test --coverage",
13+
"test:watch": "yarn run test --watch",
1414
"check": "yarn run lint && yarn run compile && yarn run test",
1515
"check:bail": "yarn run lint:bail && yarn run compile && yarn run test",
1616
"reinstall-server": "npm uninstall -g bash-language-server && yarn compile:server && npm i -g ./server"
1717
},
1818
"devDependencies": {
19-
"@types/jest": "^22.2.2",
20-
"@types/node": "^9.6.2",
21-
"jest": "^22.4.3",
22-
"prettier": "^1.11.1",
23-
"ts-jest": "^22.4.2",
24-
"tslint": "^5.9.1",
25-
"tslint-config-prettier": "^1.10.0",
26-
"tslint-plugin-prettier": "^1.3.0",
27-
"typescript": "^2.8.1",
19+
"@types/jest": "^24.0.18",
20+
"@types/node": "^12.7.5",
21+
"@typescript-eslint/eslint-plugin": "^1.10.2",
22+
"@typescript-eslint/parser": "^1.10.2",
23+
"eslint": "^5.16.0",
24+
"eslint-config-prettier": "^5.0.0",
25+
"eslint-plugin-jest": "^22.17.0",
26+
"eslint-plugin-prettier": "^3.1.0",
27+
"eslint-plugin-simple-import-sort": "^4.0.0",
28+
"jest": "^24.9.0",
29+
"prettier": "^1.18.2",
30+
"ts-jest": "^24.1.0",
31+
"typescript": "3.5.2",
2832
"vscode-languageserver": "^5.2.1"
2933
},
3034
"resolutions": {
@@ -41,21 +45,22 @@
4145
"ts"
4246
],
4347
"modulePathIgnorePatterns": [
44-
"<rootDir>/server/out"
48+
"<rootDir>/server/out",
49+
"<rootDir>/vscode-client/out"
4550
],
4651
"transform": {
47-
"\\.ts$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
52+
"\\.ts$": "ts-jest"
4853
},
4954
"globals": {
5055
"ts-jest": {
51-
"tsConfigFile": "server/tsconfig.json"
56+
"tsConfig": "./server/tsconfig.json"
5257
}
5358
},
5459
"testMatch": [
5560
"<rootDir>/**/__tests__/*.ts"
5661
],
5762
"setupFiles": [
58-
"./server/setupJest.ts"
63+
"./setupJest.ts"
5964
],
6065
"collectCoverageFrom": [
6166
"**/*.ts",

‎server/bin/main.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
2+
/* eslint-disable no-console */
23

34
const server = require('../out/index')
45
const package = require('../package')

‎server/src/__tests__/executables.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as path from 'path'
2+
23
import Executables from '../executables'
34

45
let executables: Executables = null

‎server/src/analyser.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
// tslint:disable:no-submodule-imports
21
import * as fs from 'fs'
32
import * as glob from 'glob'
43
import * as Path from 'path'
5-
64
import * as request from 'request-promise-native'
75
import * as URI from 'urijs'
8-
import * as Parser from 'web-tree-sitter'
9-
106
import * as LSP from 'vscode-languageserver'
7+
import * as Parser from 'web-tree-sitter'
118

129
import { uniqueBasedOnHash } from './util/array'
1310
import { flattenArray, flattenObjectValues } from './util/flatten'
@@ -58,8 +55,8 @@ export default class Analyzer {
5855
const absolute = Path.join(rootPath, p)
5956
// only analyze files, glob pattern may match directories
6057
if (fs.existsSync(absolute) && fs.lstatSync(absolute).isFile()) {
61-
const uri = 'file://'+absolute
62-
connection.console.log('Analyzing '+uri)
58+
const uri = `file://${absolute}`
59+
connection.console.log(`Analyzing ${uri}`)
6360
analyzer.analyze(
6461
uri,
6562
LSP.TextDocument.create(
@@ -90,9 +87,11 @@ export default class Analyzer {
9087

9188
private treeSitterTypeToLSPKind: Kinds = {
9289
// These keys are using underscores as that's the naming convention in tree-sitter.
90+
/* eslint-disable @typescript-eslint/camelcase */
9391
environment_variable_assignment: LSP.SymbolKind.Variable,
9492
function_definition: LSP.SymbolKind.Function,
9593
variable_assignment: LSP.SymbolKind.Variable,
94+
/* eslint-enable @typescript-eslint/camelcase */
9695
}
9796

9897
public constructor(parser: Parser) {

‎server/src/executables.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class Executables {
3030
/**
3131
* Find all programs in your PATH
3232
*/
33-
public list(): Array<string> {
33+
public list(): string[] {
3434
return Array.from(this.executables.values())
3535
}
3636

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /