Skip to content

Commit 25618d2

Browse files
committed
lint: Automatic import ordering
Use eslint to automatically check and fix imports, so that we don't have to worry about them anymore.
1 parent c21ac2d commit 25618d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2293
-383
lines changed

.eslintrc.json

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"extends": [
1010
"eslint:recommended",
1111
"plugin:@typescript-eslint/recommended",
12-
"prettier"
12+
"prettier",
13+
"plugin:import/recommended",
14+
"plugin:import/typescript"
1315
],
1416
"overrides": [
1517
{
@@ -19,7 +21,35 @@
1921
"@typescript-eslint/no-var-requires": "off",
2022
"@typescript-eslint/ban-ts-comment": "off",
2123
"@typescript-eslint/no-unused-vars": "off",
22-
"header/header": [2, ".header.js"]
24+
"header/header": [2, ".header.js"],
25+
"import/first": "error",
26+
"import/newline-after-import": "error",
27+
"import/order": [
28+
"error",
29+
{
30+
"alphabetize": {
31+
"order": "asc",
32+
"caseInsensitive": true
33+
},
34+
"newlines-between": "always",
35+
"distinctGroup": true,
36+
"pathGroupsExcludedImportTypes": ["builtin"],
37+
"pathGroups": [
38+
{
39+
"pattern": "@jazzer.js/**",
40+
"group": "external",
41+
"position": "after"
42+
}
43+
]
44+
}
45+
],
46+
"sort-imports": [
47+
"error",
48+
{
49+
"ignoreCase": true,
50+
"ignoreDeclarationSort": true
51+
}
52+
]
2353
}
2454
},
2555
{

examples/bug-detectors/command-injection/custom-hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
const { registerReplaceHook } = require("@jazzer.js/hooking");
1817
const {
1918
guideTowardsEquality,
2019
reportAndThrowFinding,
2120
} = require("@jazzer.js/core");
21+
const { registerReplaceHook } = require("@jazzer.js/hooking");
2222

2323
/**
2424
* Custom bug detector for command injection. This hook does not call the original function (execSync) for two reasons:

examples/bug-detectors/command-injection/fuzz.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
const { FuzzedDataProvider } = require("@jazzer.js/core");
1817
const root = require("global-modules-path");
1918

19+
const { FuzzedDataProvider } = require("@jazzer.js/core");
20+
2021
module.exports.fuzz = function (data) {
2122
const provider = new FuzzedDataProvider(data);
2223
const str1 = provider.consumeString(provider.consumeIntegralInRange(1, 20));

examples/bug-detectors/path-traversal/fuzz.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
const JSZip = require("jszip");
1817
const path = require("path");
1918

19+
const JSZip = require("jszip");
20+
2021
/**
2122
* This demonstrates the path traversal bug detector on a vulnerable version of jszip.
2223
* @param { Buffer } data

examples/protobufjs/protobufjs.fuzz.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
import fs from "fs";
18+
1719
import proto from "protobufjs";
1820
import { temporaryWriteSync } from "tempy";
19-
import fs from "fs";
2021

2122
describe("protobufjs", () => {
2223
test.fuzz("loadSync", (data) => {

fuzztests/fuzzer.fuzz.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
const { fuzzer } = require("@jazzer.js/fuzzer");
1817
const { FuzzedDataProvider } = require("@jazzer.js/core");
18+
const { fuzzer } = require("@jazzer.js/fuzzer");
1919

2020
describe("fuzzer", () => {
2121
it.fuzz("traceStrCmp", (data) => {

fuzztests/instrument.fuzz.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
const { Instrumentor } = require("@jazzer.js/instrumentor");
1817
const { FuzzedDataProvider } = require("@jazzer.js/core");
18+
const { Instrumentor } = require("@jazzer.js/instrumentor");
1919

2020
describe("instrument", () => {
2121
it.fuzz("shouldInstrumentFn", (data) => {

fuzztests/runFuzzTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
// Helper script that searches for Jest fuzz tests in the current directory and
1919
// executes them in new processes using the found fuzz test names.
2020

21-
const fs = require("fs/promises");
2221
const { spawn } = require("child_process");
22+
const fs = require("fs/promises");
2323

2424
const fuzzTestFileExtension = "fuzz.js";
2525
const fuzzTestNameRegex = /it.fuzz\s*\(\s*"(.*)"/g;

0 commit comments

Comments
 (0)