seek-oss / sku

Front-end development toolkit

Home Page:https://seek-oss.github.io/sku

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eslint import path resolution in sku

c2pig opened this issue · comments

commented

May i know is there a way to allow sku pickup .eslintrc or a way to override default eslint setting given by sku?

i have configured webpack for import path resolution, sku build is working fine, but hit the Unable to resolve path to module error when running sku lint. My configuration below :-

webpack.config.js :-

module.exports = {
  resolve: {
    modules: ['node_modules', 'src', 'components', 'wip_modules'],
    unsafeCache: true,
    cacheWithContext: false,
    symlinks: false,
    }
};

sku.config.js :-

  dangerouslySetWebpackConfig: webpackConfig => {
    return merge(webpackConfig, require('./webpack.config'));
  }

Hey Bud.

This is not something sku supports as it is a tricky problem to solve. We settled on using babel for all our module resolution so we could use the lint rules you are speaking of but also make the code work outside of a webpack environment.

The main issue we've had with using more custom webpack file resolution like you showed above, is that the code you write will now only work inside of the context of webpack. For example, If I want to unit test this code now I need webpack to compile it as the test runner won't understand some of the imports.

To simplify this we use just one module root which is the root folder for each sku project. This keeps the code less "magic" at the cost of writing longer relative imports. We feel this is a good thing as each project is less custom which means fewer things to learn when onboarding new people. The other benefit here is one day if we removed webpack and babel all together how much work would we need to do to make the code run in node. This setup would require very little.

Happy to chat further on this but as of right now there's no easy way to get your scenario working and linting in sku.

commented

thanks for the clarification :)