Skip to content

Commit

Permalink
Migrate ESLint config to flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed May 17, 2024
1 parent 51e5f00 commit 8cc9b05
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 40 deletions.
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

26 changes: 0 additions & 26 deletions .eslintrc.yml

This file was deleted.

67 changes: 67 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -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',
],
},
]
30 changes: 26 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
1 change: 0 additions & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion test/plugin.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down

0 comments on commit 8cc9b05

Please sign in to comment.