markuplint / markuplint

An HTML linter for all markup developers.
https://markuplint.dev
MIT License
554 stars 50 forks source link

`export default` doesn't work in `markuplint.config.ts` #949

Closed risu729 closed 11 months ago

risu729 commented 1 year ago

Describe the bug

ES Modules (export default) doesn't work in markuplint.config.ts

This relates to #948, but I think the cause is different.

It seems ESM is not supported at all by cosmiconfig-typescript-loader (bug: fails to load config in ESM project #60)

I consider it necessary to fix the docs to avoid confusion. https://github.com/markuplint/markuplint/blob/8c7bdb69df903289126fd5e67ee962c193c3714c/website/docs/configuration/index.md#L70-L80

Code Example

Steps To Reproduce

Run npx markuplint --config markuplint.config.ts --verbose test.html

import type { Config } from '@markuplint/ml-config'

const config: Config = {
  rules: {
    doctype: true,
  },
};

export default config

The current behavior

It fetches the specified config file but also contains other presets.

2023-04-30T15:33:16.201Z markuplint-cli:ml-engine:file Fetched Config files: Set(9) {
  '/workspaces/markuplint-test/markuplint.config.ts',
  'markuplint:code-styles',
  'markuplint:html-standard',
  'markuplint:a11y',
  'markuplint:performance',
  'markuplint:security',
  'markuplint:rdfa',
  'markuplint:recommended',
  '0'
}

The expected behavior

It should fetch only one config file, as below.

2023-04-30T15:15:41.002Z markuplint-cli:ml-engine:file Fetched Config files: Set(1) { '/workspaces/markuplint-test/markuplint.config.js' }
YusukeHirao commented 11 months ago

It resolved in https://github.com/markuplint/markuplint/pull/1198