diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 52f7ad6..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "globals": { - "H5P": "readonly", - "H5PEditor": "readonly", - "H5PIntegration": "readonly" - }, - "env": { - "browser": true, - "node": true, - "es2020": true - }, - "extends": [ - "eslint:recommended", - "plugin:jsdoc/recommended" - ], - "parserOptions": { - "sourceType": "module", - "ecmaVersion": 2020 - }, - "rules": { - "valid-jsdoc": "off", - "semi": ["error", "always"], - "indent": ["error", 2, { "SwitchCase": 1 }], - "brace-style": ["error", "stroustrup"], - "keyword-spacing": ["error", { "after": true }], - "comma-spacing": ["error", { "before": false, "after": true }], - "space-infix-ops": ["error", { "int32Hint": false }], - "eqeqeq": ["error", "smart"], - "space-before-blocks": "error", - "space-before-function-paren": ["error", { - "anonymous": "always", - "named": "never", - "asyncArrow": "always" - }], - "no-extra-boolean-cast": "off", - "no-console": ["error", { "allow": ["warn", "error"] }], - "quotes": ["error", "single"], - "arrow-parens": ["error", "always"], - "object-curly-spacing": ["error", "always"], - "no-alert": ["error"] - }, - "plugins": ["jsdoc"], - "settings": { - "jsdoc": { - "preferredTypes": { - "Function": "function" - } - } - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..ed10f8e --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,52 @@ + +import globals from 'globals'; +import jsdoc from 'eslint-plugin-jsdoc'; + +export default [ + jsdoc.configs['flat/recommended'], + { + name: 'eslint-config-snordian-h5p', + files: ['**/*.js'], + languageOptions: { + ecmaVersion: 2020, + sourceType: 'module', + globals: { + ...globals.browser, + H5P: 'readonly', + H5PEditor: 'readonly', + H5PIntegration: 'readonly' + } + }, + rules: { + semi: ['error', 'always'], + indent: ['error', 2, { 'SwitchCase': 1 }], + 'brace-style': ['error', 'stroustrup'], + 'keyword-spacing': ['error', { 'after': true }], + 'comma-spacing': ['error', { 'before': false, 'after': true }], + 'space-infix-ops': ['error', { 'int32Hint': false }], + eqeqeq: ['error', 'smart'], + 'space-before-blocks': 'error', + 'space-before-function-paren': ['error', { + 'anonymous': 'always', + 'named': 'never', + 'asyncArrow': 'always' + }], + 'no-extra-boolean-cast': 'off', + 'no-console': ['error', { 'allow': ['warn', 'error'] }], + quotes: ['error', 'single'], + 'arrow-parens': ['error', 'always'], + 'object-curly-spacing': ['error', 'always'], + 'no-alert': ['error'], + }, + plugins: { + jsdoc + }, + settings: { + jsdoc: { + preferredTypes: { + Function: 'function' + } + } + } + } +]; diff --git a/package-lock.json b/package-lock.json index 0213b83..3d1b306 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "color": "^4.2.3", + "globals": "^15.0.0", "he": "^1.2.0" }, "devDependencies": { @@ -985,6 +986,15 @@ "@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, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/plugin-transform-computed-properties": { "version": "7.24.1", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.24.1.tgz", @@ -1783,6 +1793,15 @@ "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, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.24.0", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz", @@ -5258,12 +5277,14 @@ } }, "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, + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.0.0.tgz", + "integrity": "sha512-m/C/yR4mjO6pXDTm9/R/SpYTAIyaUB4EOzcaaMEl7mds7Mshct9GfejiJNQGjHHbdMPey13Kpu4TMbYi9ex1pw==", "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globby": { diff --git a/package.json b/package.json index b6d2023..cc169df 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ }, "dependencies": { "color": "^4.2.3", + "globals": "^15.0.0", "he": "^1.2.0" }, "browserslist": "> 0.5%, last 2 versions, Firefox ESR, not dead"