Skip to content

Commit

Permalink
chore(eslint): migrate eslint v9
Browse files Browse the repository at this point in the history
Migrate major upgrade of eslint
- https://eslint.org/docs/latest/use/migrate-to-9.0.0

Ref #3727
  • Loading branch information
netil committed Apr 12, 2024
1 parent b1914fc commit 1e5842c
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 275 deletions.
76 changes: 0 additions & 76 deletions .eslintrc

This file was deleted.

5 changes: 0 additions & 5 deletions config/webpack/production.cjs
Expand Up @@ -5,7 +5,6 @@ const CleanWebpackPlugin = require("clean-webpack-plugin").CleanWebpackPlugin;
const banner = require("../template/banner.cjs");
const {EsbuildPlugin} = require("esbuild-loader");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");

const config = {
entry: {
Expand Down Expand Up @@ -50,10 +49,6 @@ const config = {
new webpack.BannerPlugin({
banner: banner.production,
entryOnly: true
}),
new ESLintPlugin({
failOnError: true,
formatter: "stylish"
})
]
};
Expand Down
95 changes: 95 additions & 0 deletions eslint.config.js
@@ -0,0 +1,95 @@
import eslint from "@eslint/js";
import jsdoc from "eslint-plugin-jsdoc";
import tseslint from 'typescript-eslint';

export default [
{
ignores: ["**/*.*(m|c)js", "node_modules/"]
},
...[
eslint.configs.recommended,
...tseslint.configs.recommended,
jsdoc.configs["flat/recommended"],
].map(conf => ({
...conf,
files: ["src/**/*.ts"]
})),
{
files: ["src/**/*.ts"],
plugins: {
jsdoc,
"@typescript-eslint": tseslint.plugin,
},
languageOptions: {
sourceType: "module",
// parser: "@typescript-eslint/parser",
parser: tseslint.parser,
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false
},
},
linterOptions: {
reportUnusedDisableDirectives: false
},
rules: {
// deprecated rules
// https://eslint.org/blog/2023/10/deprecating-formatting-rules/#the-deprecated-rules
"linebreak-style": 0,
"comma-dangle": 0,
"array-element-newline": 0,
"spaced-comment": ["error", "always", {
exceptions: ["-", "+"],
markers: ["/"]
}],
"indent": 0,
"keyword-spacing": 0,
// end of deprecated rules

"array-bracket-newline": 0,
"consistent-this": 0,
"camelcase": 0,
"no-nested-ternary": 0,
"object-shorthand": 0,
"no-lonely-if": 0,
"no-shadow": 0,
"default-case": 0,
"class-methods-use-this": 0,
"no-useless-escape": 0,
"no-loop-func": 0,
"no-use-before-define": 0,
"no-console": [
"error", {
allow: ["error"]
}
],
"import/prefer-default-export": 0,
"no-constant-binary-expression": 0,
"no-empty": 0,
"no-sequences": 0,
"no-unused-vars": "off",

// typescript rules
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-this-alias": 0,
"@typescript-eslint/no-unused-vars": [
"error", {
vars: "all",
args: "after-used",
ignoreRestSiblings: false
}
],

// jsdoc rules
"jsdoc/newline-after-description": 0,
"jsdoc/require-returns-description": 0,
"jsdoc/no-undefined-types": 0,
"jsdoc/valid-types": 0,
"jsdoc/check-values": 0,
"jsdoc/no-multi-asterisks": 0,
"jsdoc/tag-lines": 0,
"jsdoc/no-defaults": 0
}
}
];
13 changes: 6 additions & 7 deletions package.json
Expand Up @@ -36,7 +36,7 @@
"build:plugin": "cross-env NODE_ENV=plugin webpack && cross-env NODE_ENV=plugin MODE=min webpack && cross-env NODE_ENV=plugin MODE=pkgd webpack && cross-env NODE_ENV=plugin MODE=pkgd-min webpack",
"build:plugin:types": "node ./config/type.d-plugin.js",
"release": "semantic-release",
"lint": "eslint src --ext .ts",
"lint": "eslint",
"format": "dprint fmt",
"loc": "cloc --by-file src",
"test": "node --max-old-space-size=3072 ./node_modules/karma/bin/karma start ./karma.conf.cjs",
Expand Down Expand Up @@ -104,6 +104,7 @@
"devDependencies": {
"@commitlint/cli": "19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@eslint/js": "^9.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-typescript": "^11.1.6",
Expand All @@ -117,8 +118,6 @@
"@types/d3": "^7.4.3",
"@types/mocha": "^10.0.6",
"@types/sinon": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"better-docs": "^2.7.3",
"chai": "^4.3.10",
"clean-webpack-plugin": "^4.0.0",
Expand All @@ -134,11 +133,10 @@
"docdash": "^2.0.2",
"dprint": "^0.45.1",
"esbuild-loader": "^4.1.0",
"eslint": "^8.57.0",
"eslint": "^9.0.0",
"eslint-config-naver": "^2.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.2.3",
"eslint-webpack-plugin": "^4.1.0",
"eslint-plugin-jsdoc": "^48.2.2",
"exports-loader": "^5.0.0",
"hammer-simulator": "0.0.1",
"husky": "^9.0.11",
Expand Down Expand Up @@ -171,7 +169,8 @@
"style-loader": "^4.0.0",
"taffydb": "^2.7.3",
"tslib": "^2.6.2",
"typescript": "5.4.4",
"typescript": "5.4.3",
"typescript-eslint": "^7.6.0",
"webpack": "^5.91.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-clean": "^1.2.5",
Expand Down
1 change: 0 additions & 1 deletion src/Chart/api/chart.ts
Expand Up @@ -55,7 +55,6 @@ export default {

if (state.rendered) {
// reset possible zoom scale when is called from resize event
// eslint-disable-next-line prefer-rest-params
if (state.resizing) { // arguments[1] is given when is called from resize
$$.brush?.updateResize();
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/core.ts
Expand Up @@ -5,9 +5,6 @@
import Chart from "./Chart/Chart";
import {isObject, mergeObj} from "./module/util";

// eslint-disable-next-line no-use-before-define
export {bb, bb as default};

let defaults = {};

/**
Expand Down Expand Up @@ -157,3 +154,5 @@ const bb = {
*/
plugin: {}
};

export {bb, bb as default};
1 change: 0 additions & 1 deletion src/module/Cache.ts
Expand Up @@ -98,7 +98,6 @@ export default class Cache {
* @returns {object}
* @private
*/
// eslint-disable-next-line camelcase
cloneTarget(target: DataRow): DataRow {
return {
id: target.id,
Expand Down
18 changes: 9 additions & 9 deletions src/module/browser.ts
Expand Up @@ -7,15 +7,6 @@
* @private
*/
/* eslint-disable no-new-func, no-undef */
export {
cancelAnimationFrame,
cancelIdleCallback,
doc as document,
requestAnimationFrame,
requestIdleCallback,
win as window
};

/**
* Get global object
* @returns {object} window object
Expand Down Expand Up @@ -60,3 +51,12 @@ const [
requestIdleCallback,
cancelIdleCallback
] = getFallback(win);

export {
cancelAnimationFrame,
cancelIdleCallback,
doc as document,
requestAnimationFrame,
requestIdleCallback,
win as window
};

0 comments on commit 1e5842c

Please sign in to comment.