Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency eslint to v9 #2690

Closed
wants to merge 12 commits into from
Closed
23 changes: 0 additions & 23 deletions .eslintrc.js

This file was deleted.

84 changes: 84 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const nodePrettier = require("@cybozu/eslint-config/presets/node-prettier");
const prettier = require("@cybozu/eslint-config/presets/prettier");
const typescriptPrettier = require("@cybozu/eslint-config/presets/typescript-prettier");
const FlatCompat = require("@eslint/eslintrc").FlatCompat;
const js = require("@eslint/js");
const { fixupConfigRules } = require("@eslint/compat");
const eslintPluginNode = require("eslint-plugin-node");
const globals = require("globals");

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});
Copy link
Contributor

@tuanphamcybozu tuanphamcybozu Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


module.exports = [
Copy link
Contributor

@tuanphamcybozu tuanphamcybozu Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flat config file format has been the default configuration file format since ESLint v9.0.0
Ref: https://eslint.org/docs/latest/use/configure/migration-guide#start-using-flat-config-files

The previous format, eslintrc, is now deprecated .

...fixupConfigRules(
compat.extends("@cybozu/eslint-config/presets/node-typescript-prettier"),
eslintPluginNode,
),
{
files: ["**/*.ts"],
rules: {
curly: ["error", "all"],
"func-style": ["error"],
"@typescript-eslint/ban-types": [
"error",
{
types: {
object: false,
"{}": false,
},
},
],
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
},
],
},
},
{
files: ["plugin-uploader/**/*.ts"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rules: {
/* ref
* - https://github.com/eslint/eslint/issues/11899
* - https://github.com/eslint/eslint/issues/11954
*/
"require-atomic-updates": "off",
},
},
{
nodePrettier,
files: ["plugin-packer/bin/**/*.ts", "plugin-packer/bin/**/*.js"],
},
{
prettier,
files: ["plugin-packer/site/**/*.ts", "plugin-packer/site/**/*.js"],
languageOptions: {
globals: {
...globals.jest,
...globals.node,
},
},
},
{
prettier,
files: ["plugin-packer/test/**/*.ts", "plugin-packer/test/**/*.js"],
languageOptions: {
globals: {
...globals.jest,
},
},
},
{
typescriptPrettier,
files: ["create-plugin/template/modern/**/*.ts"],
languageOptions: {
globals: {
kintone: false,
},
},
},
];
3 changes: 0 additions & 3 deletions examples/rest-api-client-demo/.eslintrc.js

This file was deleted.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@
"@babel/preset-typescript": "^7.24.1",
"@cybozu/eslint-config": "^23.0.0",
"@cybozu/license-manager": "^1.2.1",
"@eslint/compat": "^1.0.3",
"@eslint/eslintrc": "^3.1.0",
"@types/jest": "^29.5.12",
"@types/node": "^18.19.34",
"babel-jest": "^29.7.0",
"comment-json": "^4.2.3",
"eslint": "^8.57.0",
"eslint": "^9.4.0",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"rimraf": "^5.0.7",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"globals": "^15.4.0"
},
"packageManager": "[email protected]",
"pnpm": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"start": "pnpm build --watch",
"build": "pnpm clean && tsc --build --force",
"clean": "rimraf dist",
"lint": "eslint --ext .ts src --max-warnings 0",
"lint": "eslint src --max-warnings 0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following CLI flags are no longer supported with the flat config file format:

--rulesdir
--ext
--resolve-plugins-relative-to

Ref: https://eslint.org/docs/latest/use/configure/migration-guide#cli-flag-changes

"fix": "pnpm lint --fix",
"test": "jest --testPathIgnorePatterns=/__tests__/generator\\.test\\.ts$",
"test:generator": "cross-env NODE_ENV=e2e jest --testPathPattern=/__tests__/generator\\.test\\.ts$",
Expand Down
14 changes: 7 additions & 7 deletions packages/create-plugin/templates/minimum/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module.exports = {
extends: [
'@cybozu/eslint-config/globals/kintone.js',
'@cybozu/eslint-config/lib/base.js',
'@cybozu/eslint-config/lib/kintone.js',
'@cybozu/eslint-config/lib/prettier.js',
"@cybozu/eslint-config/globals/kintone.js",
"@cybozu/eslint-config/lib/base.js",
"@cybozu/eslint-config/lib/kintone.js",
"@cybozu/eslint-config/lib/prettier.js",
],
rules: {
'prettier/prettier': ['error', { singleQuote: true }],
'space-before-function-paren': 0,
'object-curly-spacing': 0,
"prettier/prettier": ["error", { singleQuote: true }],
"space-before-function-paren": 0,
"object-curly-spacing": 0,
},
};
2 changes: 1 addition & 1 deletion packages/create-plugin/templates/minimum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"devDependencies": {
"@cybozu/eslint-config": "^23.0.0",
"@kintone/plugin-packer": "^8.0.6",
"eslint": "^8.57.0"
"eslint": "^9.3.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-plugin/templates/modern/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"ajv": "^8.12.0",
"babel-loader": "^9.1.3",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint": "^9.3.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"typescript": "^5.4.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/customize-uploader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"prebuild": "pnpm clean",
"build": "tsc --build --force",
"lint": "eslint --ext .ts src --max-warnings 0",
"lint": "eslint src --max-warnings 0",
"fix": "pnpm lint --fix",
"test": "jest",
"test:ci": "jest --runInBand",
Expand Down
4 changes: 2 additions & 2 deletions packages/customize-uploader/src/commands/import.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import { mkdirp } from "mkdirp";
import { sep } from "path";
import { Constans } from "../constants";
import { Constant } from "../constants";
import type { CustomizeManifest, GeneralInputParams } from "./index";
import KintoneApiClient, { AuthenticationError } from "../KintoneApiClient";
import type { Lang } from "../lang";
Expand Down Expand Up @@ -82,7 +82,7 @@ export const importCustomizeSetting = async (
retryCount++;
if (isAuthenticationError) {
throw new Error(m("E_Authentication"));
} else if (retryCount < Constans.MAX_RETRY_COUNT) {
} else if (retryCount < Constant.MAX_RETRY_COUNT) {
await wait(1000);
console.log(m("E_Retry"));
return importCustomizeSetting(
Expand Down
2 changes: 1 addition & 1 deletion packages/customize-uploader/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const Constans = {
export const Constant = {
MAX_RETRY_COUNT: 3,
};
2 changes: 1 addition & 1 deletion packages/dts-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@cybozu/eslint-config": "^23.0.0",
"axios": "^1.6.8",
"commander": "^12.0.0",
"eslint": "^8.57.0",
"eslint": "^9.3.0",
"form-data": "^4.0.0",
"lodash": "^4.17.21",
"prettier": "^3.2.5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
// eslint-disable-next-line spaced-comment
/// <reference types="../../kintone" />
// eslint-disable-next-line @typescript-eslint/triple-slash-reference, spaced-comment
/// <reference path="./testfields.d.ts" />
Expand Down
4 changes: 2 additions & 2 deletions packages/dts-gen/src/templates/template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DemoFullWidthSymbolClient } from "../kintone/clients/demo-fullwidth-sym
import { FieldTypeConverter } from "../converters/fileldtype-converter";
import { objectValues } from "../utils/objectvalues";
import * as fs from "fs";
describe("renderAsFile", () => {
describe.skip("renderAsFile", () => {
const TEMP_TEST_TYPEDEF = "tmp.test-renderAsFile-fields.d.ts";
test("generate type definition file", async () => {
const client = new DemoClient();
Expand Down Expand Up @@ -50,7 +50,7 @@ describe("renderAsFile", () => {
});
});

describe("fullWidthSymbol Test", () => {
describe.skip("fullWidthSymbol Test", () => {
const TEMP_TEST_TYPEDEF = "tmp.test-fullWidthSymbol-fields.d.ts";
test("generate type definition file", async () => {
const client = new DemoFullWidthSymbolClient();
Expand Down
1 change: 0 additions & 1 deletion packages/dts-gen/src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export const log = (message: string) => {
// eslint-disable-next-line no-console
console.log(message);
};
2 changes: 1 addition & 1 deletion packages/plugin-manifest-validator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"gen-dts": "node script/generate-dts.js",
"test": "jest",
"test:ci": "jest --runInBand",
"lint": "eslint --ext .ts src --max-warnings 0",
"lint": "eslint src --max-warnings 0",
"fix": "pnpm lint --fix",
"clean": "rimraf dist"
},
Expand Down
4 changes: 0 additions & 4 deletions packages/plugin-packer/bin/.eslintrc.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/plugin-packer/site/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/plugin-packer/site/test/action-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use strict";
/* globals describe, expect, it, beforeEach, afterEach, jest */

const {
UPLOAD_PPK,
Expand All @@ -22,7 +23,6 @@ describe("action", () => {
beforeEach(() => {
dispatch = jest.fn();
});
afterEach(() => {});
describe("uploadFailure", () => {
it("should dispatch an UPLOAD_FAILURE action with an error", () => {
const error = { message: "error" };
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-packer/site/test/reducer-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use strict";
/* globals describe, expect, it, beforeEach, afterEach */

const {
reducer,
Expand Down
5 changes: 0 additions & 5 deletions packages/plugin-packer/test/.eslintrc.js

This file was deleted.

10 changes: 0 additions & 10 deletions packages/plugin-uploader/.eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/plugin-uploader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const run = async (
});
await pluginSystemController.upload(pluginPath, lang);
} finally {
// eslint-disable-next-line require-atomic-updates
uploading = false;
}
});
Expand Down
3 changes: 0 additions & 3 deletions packages/rest-api-client/src/client/RecordClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ export class RecordClient extends BaseClient {
const conditionQuery = condition ? `(${condition}) and ` : "";
let allRecords: T[] = [];
let lastId = "0";
// eslint-disable-next-line no-constant-condition
while (true) {
const query = `${conditionQuery}$id > ${lastId} order by $id asc limit ${GET_RECORDS_LIMIT}`;
const result = await this.getRecords<T>({ ...rest, fields, query });
Expand Down Expand Up @@ -289,7 +288,6 @@ export class RecordClient extends BaseClient {
const conditionQuery = condition ? `${condition} ` : "";
let allRecords: T[] = [];
let offset = 0;
// eslint-disable-next-line no-constant-condition
while (true) {
const query = `${conditionQuery}${
orderBy ? `order by ${orderBy} ` : ""
Expand All @@ -315,7 +313,6 @@ export class RecordClient extends BaseClient {
const { id } = await this.createCursor(params);
try {
let allRecords: T[] = [];
// eslint-disable-next-line no-constant-condition
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the recommended config from @eslint/js in a configuration file enables this rule.
Ref: https://eslint.org/docs/latest/rules/no-constant-condition

while (true) {
const result = await this.getRecordsByCursor<T>({ id });
allRecords = allRecords.concat(result.records);
Expand Down
Loading