Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: add support for config files #116

Open
milahu opened this issue Feb 15, 2024 · 7 comments
Open

CLI: add support for config files #116

milahu opened this issue Feb 15, 2024 · 7 comments
Labels
enhancement New feature or request scope: cli

Comments

@milahu
Copy link

milahu commented Feb 15, 2024

i want to disable some rules for the wakaru unminify command

something like

wakaru unminify --config wakaru.json input.js

wakaru.json would be similar to .eslintrc.json

example: disable the un-jsx rule

{
  "parserOptions": {
    "sourceType": "module",
    "ecmaVersion": "latest",
  },
  "rules": {
    "un-jsx": "off"
  },
}

continue #113

i dont see a way to disable rules

You can disable it on the playground. CLI has not supported configuring the rules yet.

i guess that transforming document.createElement to JSX can be desired
so i would be happy with a

@pionxzh pionxzh added enhancement New feature or request scope: cli labels Feb 15, 2024
@pionxzh
Copy link
Owner

pionxzh commented Feb 15, 2024

Let me share the big picture in my mind.

This wakaru.json should support configuring rule orders and their enabled status. Users should be able to pass some advanced options to rules. (This is not even presented in the playground right now).

The format of eslintrc can be a reference of how this config file should structured.


Parser won't be configurable, it's fixed.

@pionxzh
Copy link
Owner

pionxzh commented Feb 15, 2024

For the user interaction part, how to generate or provide the config file is also something that needs some consideration.

@milahu
Copy link
Author

milahu commented Feb 15, 2024

should support configuring rule orders

then rules would be an array

{
  "rules": [
    ["un-jsx", "off"]
  ],
}

how to generate or provide the config file

to create a default config file

wakaru unminify --init-config wakaru.json

@0xdevalias
Copy link

0xdevalias commented Feb 16, 2024

Potentially could be something like this (object in the array, rather than array in array):

{
  "rules": [
    { rule: "un-jsx", enabled: false }
  ],
}

It's been a while since I looked how eslint handles its config for plugins/etc with extra options:

@milahu
Copy link
Author

milahu commented Feb 16, 2024

object in the array

more verbose...
plus, the rule name is required, so why not make it a positional argument

in any case, it would be nice to have javascript configs
wakaru.js wakaru.cjs wakaru.mjs

@0xdevalias
Copy link

Verbosity in a config file doesn't necessarily matter all that much if it makes things more explicit/coherent. But I don't have strong opinions either way.

Eslint seems to use a straight object for the rule config; but then I don't believe it makes use of ordering there. Technically depending how the object is iterated it can have stable ordering, but that might be too 'hidden away'/unobvious for most users.

Perhaps webpack/similar's config patterns are worth modelling on as well.

@milahu
Copy link
Author

milahu commented Feb 17, 2024

#113 (comment)

If you are running this repo in local environment, simply disable it in file packages/unminify/src/transformations/index.ts

i guess the simplest solution would be only javascript config, no json config

// wakaru.config.js

import { transformationRules } from "wakaru/unminify"

export default {
  transformationRules: transformationRules.filter(rule => {
    if (rule.name == "un-jsx") return false
    return true
  }),
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scope: cli
Projects
None yet
Development

No branches or pull requests

3 participants