Closed sidferreira closed 5 months ago
A reproduction is required. You must be misconfig the parser accidentally.
@JounQin after extra time, the problem is eslint-i18n-json
that changes all JSON files into a big comment string...
🤣 @sidferreira I think you should report there to ask them to use the correct eslint parser jsonc-eslint-parser
without any hacking.
I'm trying to do it my self. Do you3have a guide?
Well, all you should post is letting them to know there is already a correct parser, so preprocess
hacking is not required any more. But they will need to adapt the new JSON*
nodes, see also https://github.com/ota-meshi/jsonc-eslint-parser/blob/master/docs/AST.md.
And don't forget to link this issue of course.
What means that plugin is not compatible with this one.
@JounQin yeah, but I don't think they will be fast. I'll try to just create a custom solution and move on.
Your plugin does almost all the rules we want anyways
So... I'm trying to make a rule, but having a hard time:
const esCompatUtils = require('eslint-compat-utils');
// import {parse: icuMessageFormatParser} from '@formatjs/icu-messageformat-parser'
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Check JSON files for I18N messages',
},
fixable: 'code',
schema: [], // no options
},
create: function (context) {
// console.log(`>>>>`, esCompatUtils.getSourceCode(context).);
return {};
},
};
but when I try to run the test:
{
code: `
{
"translationKeyA": "translation value a",
"translationKeyB": "translation value b",
"translationKeyC": "translation value escaped curly brackets '{}'",
"translationKeyD": "translation value with backslash \u005C"
}
`,
options: [],
filename: 'file.json',
},
it throws
AssertionError [ERR_ASSERTION]: A fatal parsing error occurred: Parsing error: Unexpected token :
at runRuleForItem (.../eslint/lib/rule-tester/rule-tester.js:843:13)
at testValidTemplate (.../eslint/lib/rule-tester/rule-tester.js:896:28)
at RuleTester.<anonymous> (.../eslint/lib/rule-tester/rule-tester.js:1181:33)
at RuleTester.itDefaultHandler (.../eslint/lib/rule-tester/rule-tester.js:453:23)
at .../eslint/lib/rule-tester/rule-tester.js:1178:71
at Array.forEach (<anonymous>)
at RuleTester.<anonymous> (.../eslint/lib/rule-tester/rule-tester.js:1177:32)
at RuleTester.describeDefaultHandler (.../eslint/lib/rule-tester/rule-tester.js:470:19)
at RuleTester.<anonymous> (.../eslint/lib/rule-tester/rule-tester.js:1176:34)
at RuleTester.describeDefaultHandler (.../eslint/lib/rule-tester/rule-tester.js:470:19) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
My goal is to have a rule matching against import {parse: icuMessageFormatParser} from '@formatjs/icu-messageformat-parser'
I just tried a very small simple case, and I keep receiving this error.
Config
eslint-config.js
The target
eslint-to-test.json
cli:
What am I missing?!