linterjs / core

Lint all the things... with one command
MIT License
4 stars 0 forks source link

Configuration File #1

Closed azz closed 6 years ago

azz commented 6 years ago

No cli repository yet, so opening it here

Obviously a configuration file is required. I had a few ideas rattling in my head so I thought I'd jot down some examples.

Equivalent of eslint-config-prettier and tslint-config-prettier:

// .linterrc
{
  "rules": [
    {
      "files": "*.tsx?",
      "use": ["tslint", "prettier"]
    },
    {
      "files": ["*.jsx?", "*.md"],
      "use": ["eslint", "prettier"]
    }
  ]
}

Equivalent of prettier-eslint and prettier-tslint:

{
  "rules": [
    {
      "files": "*.tsx?",
      "use": ["prettier", "eslint"]
    },
    {
      "files": ["*.jsx?", "*.md"],
      "use": ["prettier", "eslint"]
    }
  ]
}

Passing options to a linter:

{
  "rules": [
    {
      "files": "*.js",
      "use": [
        ["prettier", { "tabWidth": 4 }],
        ["eslint", { "extends": ["standard", "prettier"] }]
      ]
    }
  ]
}

Note that the resolution for names in "use" would be:

  1. resolve("@linter/" + name)
  2. resolve("linter-" + name)
  3. resolve(name)
zimme commented 6 years ago

I'm hoping we can do without a config file tbh.

For the linting part of this, the order in which the linters run is not important. For formatting the code I'm thinking we should always run prettier first, if it's registered.

So you would basically configure @linterjs by installing the adapters that you're interested in and the adapters would run on all files they support and/or are configured to run on, via their respective config files.

Let's see how far we can get without a config file.

zimme commented 6 years ago

Let's keep the discussion going in linterjs/cli#1.