Hotell / typescript-lib-starter

Typescript library starter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get rid of most `config/` files

langpavel opened this issue · comments

Ahoj Martine!

It will be great if most of tools can work just as expected by running them.
What I can see in package.json scripts — there are mostly explicit calls with loading args from ./config/…

It isn't good for almost everyone who use command line ;-)

I expect that root folder will be bloated with hidden dot files — like:

  • .gitignore
  • .editorconfig
  • .npmignore, .npmrc
  • .prettierrc.js, .prettierignore
  • .travis.yml
  • .yarnrc ?
  • I can imagine another

but, seriously, really… I thing it is worse to keep expected config files outside than add them to their default path. Tools will be happy with everything in implicit path and tooling will behave more correctly with editors.

So, please, consider move everything which must be specified explicitly in package.json to the root,
if possible, remove config dir entirely — files inside IMHO can be moved on better path with much better semantic meaning

čau Pavle :)

I expect that root folder will be bloated with hidden dot files — like:

files that are under ./config are there for a good reason.

  • easy migration between starter-lib versions
  • narrowed type checking just for config files
  • consistent file structure ( there is setup-tests.js to be used for custom jest setup, I don't think this file belongs to root and if not in root one would have to create another folder in root with this file. Config consolidates everything together that makes sense

It isn't good for almost everyone who use command line ;-)

Hmm I think I don't understand your use-case (btw I'm heavy CLI user 😎). Everything works as expected. If you wanna execute jest or prettier from command line you can use npm scripts, which allow you to modify those, as you need by providing extra arguments, for example: yarn test --some-flags-for-jest

Tools will be happy with everything in implicit path and tooling will behave more correctly with editors.

What kind of tooling/editors are you referring to?

čau Martine :-)

I'm heavy CLI user

I'm bash user 99.99%, my first command is cat package.json :-D

  • yarn test --some-flags-for-jest vs jest
  • yarn lint..? vs tslint
  • yarn {i cannot remember} vs prettier

I'm using vscode on linux and it's extensions (tooling) + well known packages.
I spotted differences and the I rewrite half of package to fit it my needs… (sorry, no atomic commits)

BTW This starter is one of most well done on the planet 🌍 — I'm really glad

Díky za perfektní práci! :-)

I'm still leaving this open as some tools (really, VSCode extensions 😈) cannot know location of configs implicitly

yeah prettier plugin is having hard time for instance (which is very unfortunate). that's why I'm explicitly setting that in .vscode 🤷‍♂️

prettierrc has been moved to root. #162

can we close this ? :)

  • I will be happy if you can move jest config too:
    jest -c ./config/jest.config.jsjest
    Much better for cli users ;-) and required by VS Code extensions (vscode-jest, Jest Test Explorer)

  • Similar can be done with rollup (but I don't need it):
    rollup -c config/rollup.config.jsrollup -c
    See that -c argument is required, but path is optional.

    A config file is an ES module that exports a default object with the desired options. Typically, it is called rollup.config.js and sits in the root directory of your project.
    from rollupjs.org

hmm, I'm skeptical about those. I don't wanna necessarily change stuff because of some editor plugin doesn't support something.

Also my plan is to support monorepo library starter which is gonna use current codebase (I'm already using it here https://github.com/Hotell/ts-setup ). With said, that the question is, do those aforementioned plugins support monorepo etc? I personally don't use them, nor planing to do so.

Last thing. rollup config uses programatic logic, to prepare the build. I don't wanna expose js module with logic, to root file (IMHO in root should contain only static configurations)

hmm 🤔

About jest. Jest expect default config in two specific places.

  • package.json — this is no option, it is too implicit and hidden
  • jest.config.js — only implicit path

When jest is invoked without argument and none of both is matched, jest can still run with preconfigured defaults. In simple project this may work, but it does not work in this case.
IMHO --config option is there to solve special edge cases, not the implicit one.
So, you can create jest.config.js like this:

const defaultConfig = require('./config/jest.config.js');
module.exports = {
  ...defaultConfig,
  rootDir: '.',
}

But you must agree that this is ugly option. (But may works for monorepo)
Another way is move almost everything to new preset.

A preset that is used as a base for Jest's configuration. A preset should point to an npm module that has a jest-preset.json or jest-preset.js file at the root

This way it may looks really nice but it still require one file in the root

TL;DR;

It is not about tools that not supports configuration at arbitrary path

It is all about that I just wish jest to just work(TM) when I type four letters into console:
jest
See? Nothing more. Just 4 character command and works. By moving one file to expected place.