Skip to content

Commit

Permalink
Migrate to eslint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
verhovsky committed Oct 14, 2024
1 parent 98eed13 commit eb4fe44
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 34 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

59 changes: 59 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ["**/out", "**/dist", "**/*.d.ts", "**/dist", "test/fixtures/"],
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
),
{
plugins: {
"@typescript-eslint": typescriptEslint,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2018,
sourceType: "module",
},

rules: {
"no-empty": [
"error",
{
allowEmptyCatch: true,
},
],

"no-unused-vars": "off",
"no-control-regex": "off",

"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_|warnings",
caughtErrors: "none",
},
],

"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
];
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"yamljs": "^0.3.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.12.0",
"@types/diff": "^5.2.3",
"@types/har-format": "^1.2.16",
"@types/jsesc": "^3.0.3",
Expand Down Expand Up @@ -63,10 +65,10 @@
"test": "cross-env NODE_OPTIONS=\"--enable-source-maps --unhandled-rejections=strict\" npx tape dist/test/test.js",
"coverage": "c8 --check-coverage npm run test",
"prelint": "npm run compile",
"lint": "eslint src --ext ts",
"lint": "eslint src",
"format": "prettier --write .",
"prefix": "npm run compile",
"fix": "eslint src --ext ts --fix",
"fix": "eslint src --fix",
"prepare": "npx husky && npm run compile && npx tree-sitter build --wasm node_modules/tree-sitter-bash --output dist/tree-sitter-bash.wasm",
"pregen-test": "npm run compile",
"gen-test": "node --enable-source-maps ./dist/tools/gen-test.js",
Expand Down
2 changes: 1 addition & 1 deletion src/Request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ function parseRawForm(
break;
}
const [name, value] = lines[i].split(": ", 2);
if (!name === undefined || !value === undefined) {
if (name === undefined || value === undefined) {
return null;
}
if (name.toLowerCase() === "content-disposition") {
Expand Down
2 changes: 0 additions & 2 deletions src/generators/dart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ export function _toDart(requests: Request[], warnings: Warnings = []): string {
s += " final res = await http.Response.fromStream(stream);\n";
}

/* eslint-disable no-template-curly-in-string */
s +=
" final status = res.statusCode;\n" +
" if (status != 200) throw Exception('http.send" +
Expand All @@ -262,7 +261,6 @@ export function _toDart(requests: Request[], warnings: Warnings = []): string {
if (hasData) s += ", body: data";
s += ");\n";

/* eslint-disable no-template-curly-in-string */
s +=
" final status = res.statusCode;\n" +
" if (status != 200) throw Exception('http." +
Expand Down
1 change: 0 additions & 1 deletion src/generators/ruby/httparty.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { has } from "../../utils.js";
import { warnIfPartsIgnored } from "../../Warnings.js";
import { Word, eq } from "../../shell/Word.js";
import { parse, COMMON_SUPPORTED_ARGS } from "../../parse.js";
Expand Down

0 comments on commit eb4fe44

Please sign in to comment.