Skip to content

Commit

Permalink
Fix and enable linting of deno_typescript/*, tools/*, website/* (deno…
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Sep 16, 2019
1 parent c6afe87 commit 02cb34d
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 134 deletions.
15 changes: 10 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,22 @@
"@typescript-eslint/no-parameter-properties": ["off"],
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
],
"@typescript-eslint/ban-ts-ignore": ["off"],
"@typescript-eslint/no-empty-function": ["off"],
"@typescript-eslint/explicit-function-return-type": ["off"]
"@typescript-eslint/no-empty-function": ["off"]
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"files": ["*.js"],
"rules": {
"@typescript-eslint/explicit-function-return-type": ["error"]
"@typescript-eslint/explicit-function-return-type": ["off"]
}
},
{
"files": ["tools/node_*.js"],
"rules": {
"@typescript-eslint/no-var-requires": ["off"]
}
}
]
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
js/flatbuffers.js
tests/error_syntax.js
tests/badly_formatted.js
6 changes: 3 additions & 3 deletions tools/complex_permissions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class TestWritePermissions(BaseReadWritePermissionsTest,


class TestNetFetchPermissions(BaseComplexPermissionTest):
test_type = "net_fetch"
test_type = "netFetch"

def test_allow_localhost_4545(self):
code, _stdout, stderr = self._run_deno(
Expand Down Expand Up @@ -143,7 +143,7 @@ def test_allow_localhost(self):


class TestNetDialPermissions(BaseComplexPermissionTest):
test_type = "net_dial"
test_type = "netDial"

def test_allow_localhost_ip_4555(self):
code, _stdout, stderr = self._run_deno(
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_allow_localhost_ip(self):


class TestNetListenPermissions(BaseComplexPermissionTest):
test_type = "net_listen"
test_type = "netListen"

def test_allow_localhost_4555(self):
code, _stdout, stderr = self._run_deno(
Expand Down
30 changes: 14 additions & 16 deletions tools/complex_permissions_test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { args, readFileSync, writeFileSync, exit, dial } = Deno;
const { args, readFileSync, writeFileSync, exit } = Deno;

const name = args[1];
const test: (args: string[]) => void = {
read: (files: string[]): void => {
files.forEach((file): any => readFileSync(file));
read(files: string[]): void {
files.forEach(file => readFileSync(file));
},
write: (files: string[]): void => {
files.forEach(
(file): any => writeFileSync(file, new Uint8Array(), { append: true })
write(files: string[]): void {
files.forEach(file =>
writeFileSync(file, new Uint8Array(0), { append: true })
);
},
net_fetch: (hosts: string[]): void => {
hosts.forEach((host): any => fetch(host));
netFetch(hosts: string[]): void {
hosts.forEach(host => fetch(host));
},
net_listen: (hosts: string[]): void => {
hosts.forEach(
(host): any => {
const listener = Deno.listen("tcp", host);
listener.close();
}
);
netListen(hosts: string[]): void {
hosts.forEach(host => {
const listener = Deno.listen("tcp", host);
listener.close();
});
},
net_dial: async (hosts: string[]): Promise<void> => {
async netDial(hosts: string[]): Promise<void> {
for (const host of hosts) {
const listener = await Deno.dial("tcp", host);
listener.close();
Expand Down
2 changes: 1 addition & 1 deletion tools/deno_http_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function main(): Promise<void> {
}
}

async function proxyRequest(req: ServerRequest) {
async function proxyRequest(req: ServerRequest): Promise<void> {
const url = `https://${originAddr}${req.url}`;
const resp = await fetch(url, {
method: req.method,
Expand Down
6 changes: 1 addition & 5 deletions tools/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ def eslint():
print "eslint"
script = os.path.join(third_party_path, "node_modules", "eslint", "bin",
"eslint")
# TODO: Files in 'deno_typescript', 'tools' and 'website' directories are
# currently not linted, but they should.
source_files = git_ls_files(
root_path,
["*.js", "*.ts", ":!:deno_typescript/", ":!:tools/", ":!:website/"])
# Find all *directories* in the main repo that contain .ts/.js files.
source_files = git_ls_files(root_path, ["*.js", "*.ts"])
source_dirs = set([os.path.dirname(f) for f in source_files])
# Within the source dirs, eslint does its own globbing, taking into account
# the exclusion rules listed in '.eslintignore'.
Expand Down
4 changes: 2 additions & 2 deletions tools/node_tcp_promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const response = Buffer.from(
);

async function write(socket, buffer) {
let p = new Promise((resolve, reject) => {
const p = new Promise((resolve, _) => {
socket.write(buffer, resolve);
});
return p;
Expand All @@ -19,7 +19,7 @@ Server(async socket => {
socket.on("error", _ => {
socket.destroy();
});
for await (const data of socket) {
for await (const _ of socket) {
write(socket, response);
}
}).listen(port);
14 changes: 7 additions & 7 deletions tools/permission_prompt_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,41 @@ const firstCheckFailedMessage = "First check failed";

const name = args[1];
const test = {
needsRead: async () => {
async needsRead(): Promise<void> {
try {
readFileSync("package.json");
} catch (e) {
console.log(firstCheckFailedMessage);
}
readFileSync("package.json");
},
needsWrite: () => {
needsWrite(): void {
try {
makeTempDirSync();
} catch (e) {
console.log(firstCheckFailedMessage);
}
makeTempDirSync();
},
needsEnv: () => {
needsEnv(): void {
try {
env().home;
} catch (e) {
console.log(firstCheckFailedMessage);
}
env().home;
},
needsNet: () => {
needsNet(): void {
try {
listen("tcp", "127.0.0.1:4540");
} catch (e) {
console.log(firstCheckFailedMessage);
}
listen("tcp", "127.0.0.1:4541");
},
needsRun: () => {
needsRun(): void {
try {
const process = run({
run({
args: [
"python",
"-c",
Expand All @@ -49,7 +49,7 @@ const test = {
} catch (e) {
console.log(firstCheckFailedMessage);
}
const process = run({
run({
args: [
"python",
"-c",
Expand Down
Loading

0 comments on commit 02cb34d

Please sign in to comment.