-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: TypeError: Error while loading rule 'no-irregular-whitespace': sourceCode.getAllComments is not a function #299
Comments
I temporarily added |
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 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 |
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
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 eslint/json#56
The text was updated successfully, but these errors were encountered: