diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index edcfb3c8..00000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -dist/ -coverage/ -docs/ \ No newline at end of file diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 473c69e2..00000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,102 +0,0 @@ -module.exports = { - "parserOptions": { - "sourceType": "module", - }, - "env": { - "node": true, - "es2022": true - }, - "extends": ["eslint:recommended", "google"], - "plugins": [ - "jsdoc" - ], - "rules": { - "indent": [ - "error", - "tab" - ], - "linebreak-style": [ - "error", - "unix" - ], - "quotes": [ - "error", - "double", - {"allowTemplateLiterals": true} - ], - "semi": [ - "error", - "always" - ], - "no-negated-condition": "off", - "require-jsdoc": "off", - "no-mixed-requires": "off", - "max-len": [ - "error", - { - "code": 120, - "ignoreUrls": true, - "ignoreRegExpLiterals": true - } - ], - "no-implicit-coercion": [ - 2, - {"allow": ["!!"]} - ], - "comma-dangle": "off", - "no-tabs": "off", - "valid-jsdoc": 0, - // Starting with ESLint v8, it needs to be disabled as it currently can't be supported - // See: https://github.com/eslint/eslint/issues/14745 - "jsdoc/check-examples": 0, - "jsdoc/check-param-names": 2, - "jsdoc/check-tag-names": 2, - "jsdoc/check-types": 2, - "jsdoc/no-undefined-types": 0, - "jsdoc/require-description": 0, - "jsdoc/require-description-complete-sentence": 0, - "jsdoc/require-example": 0, - "jsdoc/require-hyphen-before-param-description": 0, - "jsdoc/require-param": 2, - "jsdoc/require-param-description": 0, - "jsdoc/require-param-name": 2, - "jsdoc/require-param-type": 2, - "jsdoc/require-returns": 0, - "jsdoc/require-returns-description": 0, - "jsdoc/require-returns-type": 2, - "jsdoc/tag-lines": [2, "any", {"startLines": 1}], - "jsdoc/valid-types": 0 - }, - "settings": { - "jsdoc": { - "tagNamePreference": { - "return": "returns" - } - } - }, - "root": true, - "overrides": [ - { - "files": [ - "**/*.cjs" - ], - "parserOptions": { - "sourceType": "script", - } - }, - { - "files": [ - "lib/client/**", - "test/integration/*/webapp/**/*.js", - "test/integration/*/src/**/*.js", - "test/integration/*/test/**/*.js" - ], - "env": { - "browser": true - }, - "globals": { - "sap": "readonly" - } - } - ] -}; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..22a5b2c8 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,132 @@ +import jsdoc from "eslint-plugin-jsdoc"; +import globals from "globals"; +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: ["**/dist/", "**/coverage/", "**/docs/"], + }, + ...compat.extends("eslint:recommended", "google"), + { + plugins: { + jsdoc, + }, + + languageOptions: { + globals: { + ...globals.node, + }, + + ecmaVersion: 2022, + sourceType: "module", + }, + + settings: { + jsdoc: { + tagNamePreference: { + return: "returns", + }, + }, + }, + + rules: { + "indent": ["error", "tab"], + "linebreak-style": ["error", "unix"], + + "quotes": [ + "error", + "double", + { + allowTemplateLiterals: true, + }, + ], + + "semi": ["error", "always"], + "no-negated-condition": "off", + "require-jsdoc": "off", + "no-mixed-requires": "off", + + "max-len": [ + "error", + { + code: 120, + ignoreUrls: true, + ignoreRegExpLiterals: true, + }, + ], + + "no-implicit-coercion": [ + 2, + { + allow: ["!!"], + }, + ], + + "comma-dangle": "off", + "no-tabs": "off", + "valid-jsdoc": 0, + // Starting with ESLint v8, it needs to be disabled as it currently can't be supported + // See: https://github.com/eslint/eslint/issues/14745 + "jsdoc/check-examples": 0, + "jsdoc/check-param-names": 2, + "jsdoc/check-tag-names": 2, + "jsdoc/check-types": 2, + "jsdoc/no-undefined-types": 0, + "jsdoc/require-description": 0, + "jsdoc/require-description-complete-sentence": 0, + "jsdoc/require-example": 0, + "jsdoc/require-hyphen-before-param-description": 0, + "jsdoc/require-param": 2, + "jsdoc/require-param-description": 0, + "jsdoc/require-param-name": 2, + "jsdoc/require-param-type": 2, + "jsdoc/require-returns": 0, + "jsdoc/require-returns-description": 0, + "jsdoc/require-returns-type": 2, + + "jsdoc/tag-lines": [ + 2, + "any", + { + startLines: 1, + }, + ], + + "jsdoc/valid-types": 0, + }, + }, + { + files: ["**/*.cjs"], + + languageOptions: { + ecmaVersion: 2022, + sourceType: "script", + }, + }, + { + files: [ + "lib/client/**", + "test/integration/*/webapp/**/*.js", + "test/integration/*/src/**/*.js", + "test/integration/*/test/**/*.js", + ], + + languageOptions: { + globals: { + ...globals.browser, + sap: "readonly", + }, + }, + }, +]; diff --git a/package-lock.json b/package-lock.json index 24268591..2270f875 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,8 @@ "devDependencies": { "@babel/core": "^7.24.9", "@babel/preset-env": "^7.24.8", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.8.0", "@istanbuljs/esm-loader-hook": "^0.2.0", "@openui5/sap.ui.core": "^1.126.1", "ava": "^6.1.3", @@ -31,6 +33,7 @@ "esmock": "^2.6.7", "execa": "^9.3.0", "fast-glob": "^3.3.2", + "globals": "^15.8.0", "istanbul-lib-coverage": "^3.2.2", "karma": "^6.4.3", "karma-chrome-launcher": "^3.2.0", @@ -936,6 +939,16 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-classes/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/plugin-transform-computed-properties": { "version": "7.24.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.24.7.tgz", @@ -1734,6 +1747,16 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.24.9", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.9.tgz", @@ -1845,6 +1868,7 @@ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", "dev": true, + "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", @@ -1902,6 +1926,7 @@ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.8.0.tgz", "integrity": "sha512-MfluB7EUfxXtv3i/++oh89uzAr4PDI4nn201hsp+qaXqsjAWzinlZEHEfPgAX4doIlKvPG/i0A9dpKxOLII8yA==", "dev": true, + "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } @@ -9361,12 +9386,16 @@ } }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "15.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.8.0.tgz", + "integrity": "sha512-VZAJ4cewHTExBWDHR6yptdIBlx9YSSZuwojj9Nt5mBRXQzrKakDsVKQ1J63sklLvzAJm0X5+RpO4i3Y2hcOnFw==", "dev": true, + "license": "MIT", "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globalthis": { diff --git a/package.json b/package.json index bb0f90ce..344680be 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,8 @@ "devDependencies": { "@babel/core": "^7.24.9", "@babel/preset-env": "^7.24.8", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.8.0", "@istanbuljs/esm-loader-hook": "^0.2.0", "@openui5/sap.ui.core": "^1.126.1", "ava": "^6.1.3", @@ -118,6 +120,7 @@ "esmock": "^2.6.7", "execa": "^9.3.0", "fast-glob": "^3.3.2", + "globals": "^15.8.0", "istanbul-lib-coverage": "^3.2.2", "karma": "^6.4.3", "karma-chrome-launcher": "^3.2.0",