protofire/solhint

dynamic loading of rules breaks bundlers

llllvvuu opened this issue · 3 comments

If you follow this:

const getSolhintCoreConfigPath = (name) => {
if (name === 'solhint:recommended') {
return path.resolve(__dirname, '../../conf/rulesets/solhint-recommended.js')
}

const loadRules = () => {
const rulesDir = path.join(__dirname, 'rules')
const rules = []
const files = walkSync(rulesDir)

These are all dynamic references to files that won't exist at runtime if running a bundle with eslint bundled (e.g. using esbuild, rollup, or webpack). Use-case for bundling eslint could be for a VSCode extension or a web editor.

In comparison, here is how ESLint works: https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js

IMO the eslint way is preferred also for the reason that you can quickly glance at and edit the rulesets, and is cleaner and simpler

I can put a PR for this real quick, just by dumping the resolved enabledRules into jq --sort-keys.

@llllvvuu great work !!
The team will be reviewing this

Thanks a lot for the contribution!!!