Closed adamlui closed 2 days ago
I temporarily added rules: { 'no-irregular-whitespace': 'off' }
to the config to bypass error until the bug is patched
This is working as intended as per discussion in eslint/json#56, so closing.
@fasttime check it out, I formatted markdown config like this to align w/ all my other configs:
...
{
files: ['**/*.md'], language: 'markdown/commonmark', plugins: { markdown },
rules: {
...markdown.configs.recommended[0].rules,
'markdown/heading-increment': 'off', // allow headings to skip levels
'markdown/fenced-code-language': 'off' // allow code blocks w/ no language specified
}
},
...
...and it lints MD correctly, and look how beautifully cohesive and maintainable config file now is:
import js from '@eslint/js'
import globals from 'globals'
import json from '@eslint/json'
import markdown from '@eslint/markdown'
import eslintPluginYml from 'eslint-plugin-yml'
export default [
{
files: ['**/*.js', '**/*.mjs'], ...js.configs.recommended,
rules: {
'indent': 'off', 'no-unexpected-multiline': 'off', 'key-spacing': 'off', // allow whitespace anywhere
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }], // enforce single quotes except backticks to avoid escaping quotes
'comma-dangle': ['error', 'never'], // enforce no trailing commas in arrays or objects
'no-async-promise-executor': 'off', // allow promise executor functions to be async (to accomodate await lines)
'no-constant-condition': 'off', // allow constant conditions
'no-empty': 'off', // allow empty blocks
'no-inner-declarations': 'off', // allow function declarations anywhere
'no-useless-escape': 'off', // allow all escape chars cause ESLint sucks at detecting truly useless ones
'no-unused-vars': ['error', { 'caughtErrors': 'none' }] // allow unused named args in catch blocks
},
languageOptions: {
ecmaVersion: 'latest', sourceType: 'script',
globals: {
...globals.browser, ...globals.node, ...globals.greasemonkey,
chatgpt: 'readonly', chrome: 'readonly', CryptoJS: 'readonly', dom: 'readonly', GM_cookie: 'readonly',
hljs: 'readonly', ipv4: 'readonly', marked: 'readonly', renderMathInElement: 'readonly'
}
}
},
{ files: ['**/*.mjs', '**/components/*.js', '**/lib/*.js'], languageOptions: { sourceType: 'module' }},
{ files: ['**/*.json'], ignores: ['**/package-lock.json'], language: 'json/json', ...json.configs.recommended },
{
files: ['**/*.md'], language: 'markdown/commonmark', plugins: { markdown },
rules: {
...markdown.configs.recommended[0].rules,
'markdown/heading-increment': 'off', // allow headings to skip levels
'markdown/fenced-code-language': 'off' // allow code blocks w/ no language specified
}
},
{ files: ['**/*.yaml, **/*.yml'], ...eslintPluginYml.configs['flat/standard'][1] }
]
... no outer-level configs.recommended
s to guess if it includes files
, every config obj just leads w/ files
to allow for easy scanning/adding/maintenance of new plug-ins/rules isolated to each language (thanks to your suggestion for js.configs.recommended
)
This is what new 1st-party plug-ins should aim for, keep easy maintenance of config file in mind (@eslint/json got it right since it is new I think so mindset evolved)
Glad you managed to fix your config in a way that makes it easy to maintain @adamlui. Indeed it is fine to use only certain elements of a config array like configs.recommended[0]
or configs['flat/standard'][1]
as long as the structure of those arrays doesn't change.
Environment
ESLint version: v9.14.0 @eslint/markdown version: v6.2.1 Node version: v22.9.0 npm version: v10.9.0 Operating System: Win10
Which language are you using?
commonmark
What did you do?
Configuration
```js import js from '@eslint/js' import globals from 'globals' import json from '@eslint/json' import markdown from '@eslint/markdown' export default [ js.configs.recommended, ...markdown.configs.recommended, { ignores: ['**/*.min.js', '**/sandbox/*'] }, { rules: { 'indent': 'off', 'no-unexpected-multiline': 'off', 'key-spacing': 'off', // allow whitespace anywhere 'quotes': ['error', 'single', { 'allowTemplateLiterals': true }], // enforce single quotes except backticks to avoid escaping quotes 'comma-dangle': ['error', 'never'], // enforce no trailing commas in arrays or objects 'no-async-promise-executor': 'off', // allow promise executor functions to be async (to accomodate await lines) 'no-constant-condition': 'off', // allow constant conditions 'no-empty': 'off', // allow empty blocks 'no-inner-declarations': 'off', // allow function declarations anywhere 'no-useless-escape': 'off', // allow all escape chars cause ESLint sucks at detecting truly useless ones 'no-unused-vars': ['error', { 'caughtErrors': 'none' }] // allow unused named args in catch blocks }, languageOptions: { ecmaVersion: 'latest', sourceType: 'script', globals: { ...globals.browser, ...globals.node } } }, { files: ['**/*.mjs'], languageOptions: { sourceType: 'module' }}, { files: ['**/*.json'], ignores: ['**/package-lock.json'], language: 'json/json', ...json.configs.recommended, rules: { 'no-irregular-whitespace': 'off' } } ] ```What did you expect to happen?
Lint the README.md
What actually happened?
Link to Minimal Reproducible Example
https://github.com/adamlui/js-utils
Participation
Additional comments
Same error as https://github.com/eslint/json/issues/56