I added a new eslint rule and modified the mock contracts to follow this rule. We need to update the code generator to follow this rule, either by implementing a linter that automatically fixes the output code or by modifying the code generator to understand when it needs to import as a type.
I tried to solve this by including and programmatically using eslint, which does in fact work, but only in dev mode.
I couldn't figure out how to get the eslint API working after you build the cli app and then ran it externally. The rollup bundle didn't include the plugins (like @typescript-eslint/eslint-plugin) and would result in errors like:
An error occurred while generating the contract code: Error: Failed to load plugin '@typescript-eslint' declared in 'CLIOptions': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /Users/aaron/projects/wharfkit/example-svelte-ts/__placeholder__.js
Referenced from: CLIOptions
node:internal/modules/cjs/loader:995
const err = new Error(message);
^
Error: Failed to load plugin '@typescript-eslint' declared in 'CLIOptions': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /Users/aaron/projects/wharfkit/example-svelte-ts/__placeholder__.js
Referenced from: CLIOptions
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Function.resolve (node:internal/modules/cjs/helpers:109:19)
at Object.resolve (/Users/aaron/projects/wharfkit/cli/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2337:46)
at ConfigArrayFactory._loadPlugin (/Users/aaron/projects/wharfkit/cli/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3404:33)
at ConfigArrayFactory._loadExtendedPluginConfig (/Users/aaron/projects/wharfkit/cli/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3224:29)
at ConfigArrayFactory._loadExtends (/Users/aaron/projects/wharfkit/cli/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3145:29)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/aaron/projects/wharfkit/cli/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3086:25)
at _normalizeObjectConfigDataBody.next (<anonymous>)
at ConfigArrayFactory._normalizeObjectConfigData (/Users/aaron/projects/wharfkit/cli/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3031:20)
at _normalizeObjectConfigData.next (<anonymous>) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/aaron/projects/wharfkit/example-svelte-ts/__placeholder__.js'
],
messageTemplate: 'plugin-missing',
messageData: {
pluginName: '@typescript-eslint/eslint-plugin',
resolvePluginsRelativeTo: '/Users/aaron/projects/wharfkit/example-svelte-ts',
importerName: 'CLIOptions'
}
}
I added a new eslint rule and modified the mock contracts to follow this rule. We need to update the code generator to follow this rule, either by implementing a linter that automatically fixes the output code or by modifying the code generator to understand when it needs to import as a type.
I tried to solve this by including and programmatically using
eslint
, which does in fact work, but only in dev mode.I couldn't figure out how to get the
eslint
API working after you build the cli app and then ran it externally. The rollup bundle didn't include the plugins (like@typescript-eslint/eslint-plugin
) and would result in errors like: