Open kaelig opened 1 year ago
See https://github.com/steelsojka/eslint-import-alias
I have the code ready because I needed it for my codebase!
Desired output:
// Before { "~actions/*": ["src/actions/*"], "~ui/*": ["src/components/ui/*"], } // After [ { alias: '~actions', matcher: '^src\/actions' }, { alias: '~ui', matcher: '^src\/components\/ui' }, ]
It should look something like this:
const { toArray } = require('../../utils') // @see https://github.com/steelsojka/eslint-import-alias#configure function callback (name, [path], config, options) { return { alias: name.replace('/*', ''), matcher: '^' + path.replace('/*', '').replaceAll('/', '\\/').replaceAll(/\.([a-zA-Z]+)/g, '\\.$1'), } } module.exports = function (config, options) { return toArray(callback, config, options) }
And the test:
module.exports = [ function () { const expected = [ { alias: '@', matcher: '^' }, { alias: '@packages', matcher: '^..\\/packages' }, { alias: '@classes', matcher: '^classes' }, { alias: '@app', matcher: '^app' }, { alias: '@data', matcher: '^app\\/data' }, { alias: '@settings', matcher: '^app\\/settings\\.js' }, { alias: '@services', matcher: '^app\\/services' }, { alias: '@views', matcher: '^app\\/views' } ] return { expected } }, ]
Let me know if you're interested in me adding the plugin + docs to the codebase!
Hello! Thanks for the contribution.
My next task is to refactor the the library to typescript, so let me check in again after that's done 🙏
See https://github.com/steelsojka/eslint-import-alias
I have the code ready because I needed it for my codebase!
Desired output:
It should look something like this:
And the test:
Let me know if you're interested in me adding the plugin + docs to the codebase!