From 8cc9b050583c93430076306f5fb72dedfddcdd08 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Sat, 18 May 2024 01:33:49 +0900 Subject: [PATCH 1/3] Migrate ESLint config to flat config --- .eslintignore | 7 ----- .eslintrc.yml | 26 ------------------ eslint.config.mjs | 67 +++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 30 ++++++++++++++++++--- package.json | 3 ++- src/plugin.js | 1 - test/plugin.js | 2 +- 7 files changed, 96 insertions(+), 40 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.yml create mode 100644 eslint.config.mjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 24bcf45d..00000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -coverage/ -dist/ -docs/ -lib/ -node_modules -jsdoc/ -plugin.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 41ae3579..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,26 +0,0 @@ -env: - es6: true - node: true - -extends: - - eslint:recommended - - plugin:import-x/recommended - - prettier - -parser: '@babel/eslint-parser' - -rules: - import-x/order: - - error - - alphabetize: - order: 'asc' - - max-len: - - error - - 80 - - 2 - - ignoreUrls: true - ignoreComments: false - ignoreRegExpLiterals: true - ignoreStrings: true - ignoreTemplateLiterals: true diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..7f87c11a --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,67 @@ +import babelParser from '@babel/eslint-parser' +import js from '@eslint/js' +import eslintConfigPrettier from 'eslint-config-prettier' +import eslintPluginImportX from 'eslint-plugin-import-x' +import globals from 'globals' + +export default [ + js.configs.recommended, + // eslintPluginImportX.configs.recommended, // not yet available + eslintConfigPrettier, + { + languageOptions: { + parser: babelParser, + globals: { + ...globals.node, + }, + }, + linterOptions: { + reportUnusedDisableDirectives: 'error', + }, + plugins: { + import: eslintPluginImportX, + }, + rules: { + 'import/order': [ + 'error', + { + alphabetize: { + order: 'asc', + }, + }, + ], + 'max-len': [ + 'error', + { + code: 80, + tabWidth: 2, + ignoreUrls: true, + ignoreComments: false, + ignoreRegExpLiterals: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + }, + ], + }, + }, + { + files: ['test/**/*', 'jest.*'], + languageOptions: { + globals: { + ...globals.jest, + context: 'readonly', + }, + }, + }, + { + ignores: [ + 'coverage/**/*', + 'dist/**/*', + 'docs/**/*', + 'jsdoc/**/*', + 'lib/**/*', + 'node_modules/**/*', + 'plugin.js', + ], + }, +] diff --git a/package-lock.json b/package-lock.json index 3bbad138..acf05c0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "eslint": "^9.2.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import-x": "^0.5.0", + "globals": "^15.2.0", "jest": "^29.7.0", "jest-junit": "^16.0.0", "jsdoc": "^4.0.3", @@ -1009,6 +1010,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", @@ -1807,6 +1817,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.5", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.5.tgz", @@ -6522,12 +6541,15 @@ } }, "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.2.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.2.0.tgz", + "integrity": "sha512-FQ5YwCHZM3nCmtb5FzEWwdUc9K5d3V/w9mzcz8iGD1gC/aOTHc6PouYu0kkKipNJqHAT7m51sqzQjEjIP+cK0A==", "dev": true, "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globby": { diff --git a/package.json b/package.json index 88f3d655..cb104aae 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "docs:style": "node ./docsify/build.js", "format": "prettier \"**/*.{css,html,js,json,md,scss,ts,yaml,yml}\"", "jsdoc": "rimraf jsdoc && jsdoc src -c .jsdoc.json", - "lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint --report-unused-disable-directives .", + "lint:js": "eslint", "lint:css": "stylelint \"./**/*.{css,scss}\"", "prepack": "npm-run-all --parallel check:* lint:* test:coverage --sequential build", "preversion": "run-p check:* lint:* test:coverage", @@ -73,6 +73,7 @@ "eslint": "^9.2.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import-x": "^0.5.0", + "globals": "^15.2.0", "jest": "^29.7.0", "jest-junit": "^16.0.0", "jsdoc": "^4.0.3", diff --git a/src/plugin.js b/src/plugin.js index f53afd8a..c286a71a 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -28,7 +28,6 @@ * @returns {Function} Generated Marpit plugin. */ function marpitPlugin(plugin) { - // eslint-disable-next-line func-names return function (md, ...args) { if (md.marpit) return plugin.call(this, md, ...args) diff --git a/test/plugin.js b/test/plugin.js index 7470f3b9..4c8e1ec4 100644 --- a/test/plugin.js +++ b/test/plugin.js @@ -1,7 +1,7 @@ import markdownIt from 'markdown-it' +import { Marpit } from '../src/index' import pluginAsDefaultExport from '../src/plugin' import { marpitPlugin } from '../src/plugin' -import { Marpit } from '../src/index' describe('Plugin interface', () => { it('is compatible as CommonJS module', () => { From a11e2d404939db8bc3ef845af1b9df117483c1ec Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Sat, 18 May 2024 01:38:10 +0900 Subject: [PATCH 2/3] Remove unused ESLint comments and config files --- docsify/.eslintrc.yml | 3 --- jest.setup.js | 1 - src/postcss/import/parse.js | 1 - test/.eslintrc.yml | 5 ----- 4 files changed, 10 deletions(-) delete mode 100644 docsify/.eslintrc.yml delete mode 100644 test/.eslintrc.yml diff --git a/docsify/.eslintrc.yml b/docsify/.eslintrc.yml deleted file mode 100644 index 11c5b49a..00000000 --- a/docsify/.eslintrc.yml +++ /dev/null @@ -1,3 +0,0 @@ -rules: - import/no-extraneous-dependencies: off - no-console: off diff --git a/jest.setup.js b/jest.setup.js index 1c827738..af8d02dc 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -1,2 +1 @@ -/* eslint-env jest */ global.context = describe diff --git a/src/postcss/import/parse.js b/src/postcss/import/parse.js index a3f58cd7..87d53fa5 100644 --- a/src/postcss/import/parse.js +++ b/src/postcss/import/parse.js @@ -1,4 +1,3 @@ -/* eslint consistent-return: 0 */ /** @module */ import postcssPlugin from '../../helpers/postcss_plugin' diff --git a/test/.eslintrc.yml b/test/.eslintrc.yml deleted file mode 100644 index 04ebdfa0..00000000 --- a/test/.eslintrc.yml +++ /dev/null @@ -1,5 +0,0 @@ -env: - jest: true - -globals: - context: true From 59baec72167bab50df1886737625fd747ba861c9 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Sat, 18 May 2024 01:40:54 +0900 Subject: [PATCH 3/3] [ci skip] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dceadce2..0edab210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,11 @@ ### Changed +- Bump markdown-it to [v14.1.0](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md#1410---2024-03-19), and follow the latest spec of [CommonMark 0.31.2](https://spec.commonmark.org/0.31.2/) ([#393](https://github.com/marp-team/marpit/pull/393)) - Switch package manager from yarn to npm ([#391](https://github.com/marp-team/marpit/pull/391)) - Upgrade development Node.js to v20 LTS ([#392](https://github.com/marp-team/marpit/pull/392)) -- Bump markdown-it to [v14.1.0](https://github.com/markdown-it/markdown-it/blob/master/CHANGELOG.md#1410---2024-03-19), and follow the latest spec of [CommonMark 0.31.2](https://spec.commonmark.org/0.31.2/) ([#393](https://github.com/marp-team/marpit/pull/393)) - Upgrade dependent packages to the latest version ([#393](https://github.com/marp-team/marpit/pull/393)) +- Migrate ESLint config to Flat config ([#394](https://github.com/marp-team/marpit/pull/394)) ### Removed