eslint-plugin-jsonc icon indicating copy to clipboard operation
eslint-plugin-jsonc copied to clipboard

Difficulty in using your plugin

Open darkgreentree opened this issue 9 months ago • 0 comments

Hello. I create a ESLint config and export it like this:

// myESLintConfig.js

import jsdoc from 'eslint-plugin-jsdoc';
import importx from 'eslint-plugin-import-x';
import jsonc from 'eslint-plugin-jsonc';

import configESLint from './configESLint.json' assert { type: 'json' };
import configImportX from './configImportX.json' assert { type: 'json' };
import configJSDOC from './configJSDoc.json' assert { type: 'json' };
import configJsonC from './configJsonC.json' assert { type: 'json' };

export const myESLintConfig = {
  languageOptions: {
    ecmaVersion: 'latest',
    globals: {
      ...globals.browser,
    },
    parserOptions: {
      ecmaVersion: 'latest',
    },
  },
  plugins: {
    'import-x': importx,
    jsdoc,
    jsonc,
  },
  rules: {
    ...configESLint.rules,
    ...configImportX.rules,
    ...configJSDOC.rules,
    ...configJsonC.rules,
  },
  settings: {
    'import-x/parsers': {
      espree: ['.js'],
    },
  },
};

// configJsonC.json

{
  "rules": {
    "jsonc/auto": "error",
    "jsonc/key-name-casing": "error",
    ...
}

The rules of each ESLint plugin are imported from separated .json files. When the config above is used by ESLint in a given project, I run the "lint:js" command, that is a simple "eslint ./" command. In In this situation, all the plugins work as expected, except your plugin. I don't know what I am doing wrong. Can you please show me the way?

Do I need to add the parser, like this?...

settings: {
  "jsonc-eslint-parser": {
    "@babel/eslint-parser": ["*.json", "*.json5", "*.jsonc"],
  }
}

...(I would like to avoid it, because I don't use @babel at all)

In a first moment, I would like to make your plugin work in my config. In a second moment, I would like to create another command called "lint:json" side-by-side with "lint:js". So it is better to consider this distinction of interests when setting up the config.

I appreciate any guidance you can provide. I already spent hours and read your documentation. This may be one of those obvious mistakes.

darkgreentree avatar May 22 '24 19:05 darkgreentree