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

Autocreate configuration from existing project code #3567

Closed
IanVS opened this issue Aug 28, 2015 · 22 comments
Closed

Autocreate configuration from existing project code #3567

IanVS opened this issue Aug 28, 2015 · 22 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features feature This change adds a new feature to ESLint
Milestone

Comments

@IanVS
Copy link
Member

IanVS commented Aug 28, 2015

This issue is for discussion of a new feature which would generate a configuration file based on the code styles and conventions already in use in a project.

Background: When new users are adding ESLint to an existing project, the first step is often to sift through the many ESLint rules to find the ones which are applicable to the project. While it might be easy to simply enable all of the Possible Errors and Best Practices rules, Stylistic Issues are much more subjective and need to be carefully examined, one-by-one.

What is being proposed here is to allow the code style already in use in the project to guide the creation of an .eslintrc configuration file.

The most likely way this can be accomplished is by repeatedly linting the code with rules set with different options, and comparing the number of linting errors that result from each option. Now that ea1871f has landed, it should only be necessary to parse the code once, thereby improving performance.

What still needs some thought and discussion, is the criteria for deciding which rules to enable in the generated config. Some ideas:

  • Only enable rules which result in zero errors.
    • Advantage: Up-and-running right away, build does not break, nothing to fix.
    • Downside: If linting was not previously being done in the project, it's possible the code is mostly-consistent but has a few problems here and there which should be fixed.
  • Set rules to warn if results < a threshold (configurable at runtime?)
    • Advantage: Can catch some problems in the code right away.
    • Downside: Requires some action on user's part if configurable. If not, a threshold has to be determined a priori
  • When testing options like "always" vs. "never", if there are errors for both options, set to warn if one option has < X% of the errors when set to the other option. For example, if "always" gives 5 errors, and "never" gives 100, it's likely the style in the project is "always", and those 5 errors are just errors. However, if both options give 50 errors each, the project probably doesn't want to enforce that rule at all.
    • Advantage: Able to set rules with more complicated options, while allowing for some degree of imperfection in the project.
    • Disadvantage: A threshold would need to either be hard-coded or configurable at runtime.

A secondary goal of this is to be runnable against a project already using ESLint, to pick up new rules or make rules more strict if they are not erroring (see #3436).

@IanVS IanVS added core Relates to ESLint's core APIs and features needs bikeshedding Minor details about this change need to be discussed feature This change adds a new feature to ESLint labels Aug 28, 2015
@IanVS IanVS self-assigned this Aug 28, 2015
@IanVS IanVS added this to the v2.0.0 milestone Aug 28, 2015
@nzakas nzakas added the accepted There is consensus among the team that this change meets the criteria for inclusion label Aug 28, 2015
@nzakas
Copy link
Member

nzakas commented Aug 28, 2015

Let's split out that secondary goal into a different feature. The bootstrapping experience is the top priority for us.

@IanVS IanVS added the cli Relates to ESLint's command-line interface label Aug 28, 2015
@nzakas nzakas mentioned this issue Aug 28, 2015
11 tasks
@ilyavolodin
Copy link
Member

Just as a reference there's a tool out there that does some of this: https://github.com/willklein/dryer

@nzakas
Copy link
Member

nzakas commented Aug 28, 2015

Yeah, we wanted to reach out to see if incorporating it would be an option.

@IanVS
Copy link
Member Author

IanVS commented Aug 29, 2015

Yep, @willklein and I have chatted, and he did a little investigatory work a while back towards integrating into ESLint. Then I think we both took a break until #1025 and #948 were addressed. Now that those are complete, I think we can jump back into it. I'm starting by putting together a small tool which will create rule combinations, which dryer does not currently do.

@IanVS
Copy link
Member Author

IanVS commented Sep 14, 2015

I was talking with @MiguelCastillo, and he had the idea to pick a reasonable number (half dozen or so) of the most popular rules and start by autoconfiguring just those, and then add more in as demand dictates. My original thinking had been to examine all rules against the target project (or at least those rules with enumerable/binary configurations). Thoughts?

@ilyavolodin
Copy link
Member

Knowing how many rules we have that support more then one option, I think we might be talking about thousands of permutations here. I'm not sure all rules can be run against target. All rules without options would be fine though, I think.

@IanVS
Copy link
Member Author

IanVS commented Sep 14, 2015

@ilyavolodin Is your concern about performance, user experience, or difficulty of implementation (or maybe something else)? Many of the more useful rules have enum options of just two values (such as "always" and "never") so they wouldn't add much overhead. Open-ended options like complexity likely won't make sense, and those with options containing multiple properties could quickly get out of hand, as you say. But let's keep in mind this is a feature which will likely only be used one time in a project's lifespan, so I'm not sure performance should be the main constraint here (as long as it's not ridiculous).

@nzakas
Copy link
Member

nzakas commented Sep 14, 2015

If we just take a small subset of rules, then I'm not sure it will be much more useful than what --init already does. I agree that performance shouldn't be a factor here so long as it doesn't take minutes.

@willklein
Copy link

My initial testing showed it would take multiple (potentially many) minutes, but there have since been enhancements that should help us optimize this. Specifically, #948 and #1025 might help.

I also think we should be able to handle the enumerable options, and we should test and configure the full set of rules with very few, if any, exceptions. For rules that can't be enumerated, it may suffice to test the default configuration.

@nzakas
Copy link
Member

nzakas commented Sep 15, 2015

Can we cut into that time by pre-generating all possible rule configurations (maybe at release time)?

@IanVS
Copy link
Member Author

IanVS commented Sep 15, 2015

That's probably a good idea. Let's see how long that generation takes first. I have a feeling it will be a drop in the bucket compared to the time needed for actually linting over and over with those configurations. I have some thoughts how to do that more efficiently as well, but need to do more thinking and prototyping to flesh them out.

@IanVS
Copy link
Member Author

IanVS commented Sep 24, 2015

Getting started on this. So far I'm generating configurations for empty schemas and enums.

@IanVS IanVS removed the needs bikeshedding Minor details about this change need to be discussed label Sep 24, 2015
@IanVS
Copy link
Member Author

IanVS commented Oct 16, 2015

I'm now also generating configs for some config object properties (enums). My thinking is to create configurations with all properties set explicitly (i.e. no defaults), so for instance, the configurations I check for key-spacing are currently:

   [ [ 2, { align: 'colon', mode: 'strict' } ],
     [ 2, { align: 'colon', mode: 'minimum' } ],
     [ 2, { align: 'value', mode: 'strict' } ],
     [ 2, { align: 'value', mode: 'minimum' } ] ]

And once the boolean properties beforeColon and afterColon are added, there will be a total of 16 combinations, each having all properties set. Can anyone think of any problems with this approach?

@nzakas
Copy link
Member

nzakas commented Oct 16, 2015

I think that's fine. I generally believe being explicit is better than trusting defaults anyway. :)

@IanVS
Copy link
Member Author

IanVS commented Oct 17, 2015

Turns out that approach may not make sense for lines-around-comment, which has 10 boolean options. Rather than linting 1,024 times to check every possible combination, it would be better to check each option individually. All the other rules have reasonable numbers of combinations (two have 16, the rest have < 10).

@IanVS
Copy link
Member Author

IanVS commented Oct 24, 2015

Is it reasonable to expect (at least for an initial implementation) the user to manually create an .eslintrc file with any necessary environments set correctly, before running autoconfig? Otherwise, if they start from a project which uses es6 syntax, esprima will choke and the code won't be lintable. One way to solve this might be to try to autoconfigure the environments as well, but I see that as a fairly significant effort which might make for a nice enhancement in the future. What say ye?

@IanVS
Copy link
Member Author

IanVS commented Oct 24, 2015

Here's another idea. Instead of adding a new --autoconfigure command as I had been planning, how about we add autoconfig as an option we give users when they are running through --init? That way, the question regarding es6 and node has already been asked, and the .eslintrc creation logic is already there. I'm imagining that instead of asking about a few rules like quote style and tabs/spaces, we ask if we should try to determine rules based on their code, and if the answer is no, then we can still ask the more basic questions as before.

@ilyavolodin
Copy link
Member

That's what I was going to suggest. Either make it part of the --init or just ask a question about jsx and es6 before you kick off autoconfig.

@nzakas
Copy link
Member

nzakas commented Oct 24, 2015

👍

@nzakas
Copy link
Member

nzakas commented Oct 24, 2015

Oops, meant 👍 to making it part of --init. We should start of by saying, "How do you want to create your config? Inspect your JavaScript file, Answer questions"

@ilyavolodin
Copy link
Member

I just ran autoconfig on a new repository and have a a few comments for the future. I wouldn't want to add those to the initial implementation, but wanted to record them somewhere for future enhancements:

  1. It would be great to have an aggressive mode. What that would mean is for any rule that is fixable, set the config value to the style with lowest number of errors and auto-fix it after config file is generated.
  2. Adding threshold for number of errors has already been discussed, but still, wanted to mention it here again. I don't want rules with just a few errors to be automatically turned off.
  3. We might want to ask if the user wants to run eslint with new configuration once it's created.
  4. Would be nice to sort rules based on their state in the config file. So everything that is off should go to the bottom (for example).
  5. Eventually, once we have full metadata, we could add comments with short description of the rule next to it.

@IanVS
Copy link
Member Author

IanVS commented Jan 21, 2016

Thanks, those are great ideas. Some other pieces I haven't had time to implement so far:

  1. Allow ES7+ features with option for using babel-eslint. For now, such code is not autoconfigurable (parser is always set to espree).
  2. Enable autoconfig of rules with schemas containing nested objects and oneOf or anyOf schemas.
  3. Add a mode for projects which are already using ESLint to check if they can easily enable more rules than they currently have in their config (either newly added rules, or the code has been refactored, etc.).

Metadata will be very useful for a number of reasons, as you've mentioned already. Right now the rules are being sorted alphabetically, which seemed to be the only logical order when we're talking about 200 rules, since it makes them easier to find if you're just scanning through. I thought about grouping on/off rules, but I think that's less desirable in the long run, since configs are not static, and personally I don't like to reorder my rules when I turn them on and off. But, maybe we can play with groupings that make sense.

IanVS pushed a commit that referenced this issue Jan 22, 2016
This adds an option to `--init`, which will ask for a set of files to examine,
and then lint those files with various rule configuration settings.  Based on the
results of that linting, it will generate a configuration file which minimizes
the number of errors.

Rules in `eslint:recommended` will not be disabled, so they may still result in
erorrs, but all other rules will not give errors when linted against the same set
of files which was examined.

This also adds some utility functions, like `getSourceCodeOfFiles()` from
`lib/util/source-code-util.js`, utilities for working with npm (`lib/util/npm-util.js`)
and it extracts the default cli options into `conf/cli-options.js`.

At this time, this feature cannot be used for JSX code, due to #5007.

Commits which were squashed into this commit:

74869b5 Create autoconfig module
0d01ec3 Address comments so far
ebb9e56 Create helper for obtaining SourceCode from file(s)
c5215b6 Add autogenerate option to `—-init`
e00cb80 Add logic for collecting linting errors by rule config
ea614d0 Create config files with sorted keys
ab0a899 Add logic to choose “best” rule configs
1345e49 Do not initialize errorCount in registry to zero
5350fe5 Add a progress bar for reporting execution time.
7bec887 Use new parserOptions
06bedcc Remove manual rule blacklist
dc95669 Define ruleConfig and registryItem in JSDoc typedefs
2036ec5 Avoid populating registry upon construction
6581c18 Refactor and improve
f3290b8 Extend from “eslint:recommended”
7f39778 Doc cleanup
545a229 Break up Registry methods
aa7318b Split rule configuration from autoconfig
8a370cc Only disable rules which have no determined error-free config
9033b62 Do not disable eslint:recommended rules
a18b766 Add tests for config generation from schema
43c54b8 Pull default CLIEngineConfig into config file
10c0ea7 Add tests for createCoreRuleConfigs()
f032556 Add initial tests for SourceCodeObtain
aded766 Make options optional for getSourceCodeOfFiles
2480b42 Add more tests for SourceCodeObtain
67a8e75 Don’t export RuleConfigSet
9378f75 Account for new location of ecmaFeatures in config
3691dd4 Add some tests for config-initializer processAnswers()
3362eb9 Pass around Inquirer ui object explicitly
f8b1689 Rename `source-code-obtain` to `source-code-util`
3199afa Use Uppercase for Object and Registry in JSDoc
b39832a Install eslint-plugin-react before autoconfig runs
4c336fa Ask if the project is using ES6 modules
5e27d5c Pull npm installation into separate utility
b99d288 Add cwd to default cli options
ec526b3 Cleanups based on @gyandeeps’s review
1fcdc7b Stub out npm utility functions
36ed7e6 Fix bug when schema contains an enum and empty obj
dd64ffc Add initial tests for autoconfig
59a7247 Use logging utility
f486a5b Extend options from the defaults
bb2f63d Add more tests for autoconfig
f80d36e Disable autoconfig for JSX code, for now
IanVS pushed a commit that referenced this issue Jan 24, 2016
This adds an option to `--init`, which will ask for a set of files to examine,
and then lint those files with various rule configuration settings.  Based on the
results of that linting, it will generate a configuration file which minimizes
the number of errors.

Rules in `eslint:recommended` will not be disabled, so they may still result in
erorrs, but all other rules will not give errors when linted against the same set
of files which was examined.

This also adds some utility functions, like `getSourceCodeOfFiles()` from
`lib/util/source-code-util.js`, utilities for working with npm (`lib/util/npm-util.js`)
and it extracts the default cli options into `conf/cli-options.js`.

At this time, this feature cannot be used for JSX code, due to #5007.

Commits which were squashed into this commit:

74869b5 Create autoconfig module
0d01ec3 Address comments so far
ebb9e56 Create helper for obtaining SourceCode from file(s)
c5215b6 Add autogenerate option to `—-init`
e00cb80 Add logic for collecting linting errors by rule config
ea614d0 Create config files with sorted keys
ab0a899 Add logic to choose “best” rule configs
1345e49 Do not initialize errorCount in registry to zero
5350fe5 Add a progress bar for reporting execution time.
7bec887 Use new parserOptions
06bedcc Remove manual rule blacklist
dc95669 Define ruleConfig and registryItem in JSDoc typedefs
2036ec5 Avoid populating registry upon construction
6581c18 Refactor and improve
f3290b8 Extend from “eslint:recommended”
7f39778 Doc cleanup
545a229 Break up Registry methods
aa7318b Split rule configuration from autoconfig
8a370cc Only disable rules which have no determined error-free config
9033b62 Do not disable eslint:recommended rules
a18b766 Add tests for config generation from schema
43c54b8 Pull default CLIEngineConfig into config file
10c0ea7 Add tests for createCoreRuleConfigs()
f032556 Add initial tests for SourceCodeObtain
aded766 Make options optional for getSourceCodeOfFiles
2480b42 Add more tests for SourceCodeObtain
67a8e75 Don’t export RuleConfigSet
9378f75 Account for new location of ecmaFeatures in config
3691dd4 Add some tests for config-initializer processAnswers()
3362eb9 Pass around Inquirer ui object explicitly
f8b1689 Rename `source-code-obtain` to `source-code-util`
3199afa Use Uppercase for Object and Registry in JSDoc
b39832a Install eslint-plugin-react before autoconfig runs
4c336fa Ask if the project is using ES6 modules
5e27d5c Pull npm installation into separate utility
b99d288 Add cwd to default cli options
ec526b3 Cleanups based on @gyandeeps’s review
1fcdc7b Stub out npm utility functions
36ed7e6 Fix bug when schema contains an enum and empty obj
dd64ffc Add initial tests for autoconfig
59a7247 Use logging utility
f486a5b Extend options from the defaults
bb2f63d Add more tests for autoconfig
f80d36e Disable autoconfig for JSX code, for now

Plus a few others ...
IanVS pushed a commit that referenced this issue Jan 25, 2016
This adds an option to `--init`, which will ask for a set of files to examine,
and then lint those files with various rule configuration settings.  Based on the
results of that linting, it will generate a configuration file which minimizes
the number of errors.

Rules in `eslint:recommended` will not be disabled, so they may still result in
erorrs, but all other rules will not give errors when linted against the same set
of files which was examined.

This also adds some utility functions, like `getSourceCodeOfFiles()` from
`lib/util/source-code-util.js`, utilities for working with npm (`lib/util/npm-util.js`)
and it extracts the default cli options into `conf/cli-options.js`.

At this time, this feature cannot be used for JSX code, due to #5007.

Commits which were squashed into this commit:

74869b5 Create autoconfig module
0d01ec3 Address comments so far
ebb9e56 Create helper for obtaining SourceCode from file(s)
c5215b6 Add autogenerate option to `—-init`
e00cb80 Add logic for collecting linting errors by rule config
ea614d0 Create config files with sorted keys
ab0a899 Add logic to choose “best” rule configs
1345e49 Do not initialize errorCount in registry to zero
5350fe5 Add a progress bar for reporting execution time.
7bec887 Use new parserOptions
06bedcc Remove manual rule blacklist
dc95669 Define ruleConfig and registryItem in JSDoc typedefs
2036ec5 Avoid populating registry upon construction
6581c18 Refactor and improve
f3290b8 Extend from “eslint:recommended”
7f39778 Doc cleanup
545a229 Break up Registry methods
aa7318b Split rule configuration from autoconfig
8a370cc Only disable rules which have no determined error-free config
9033b62 Do not disable eslint:recommended rules
a18b766 Add tests for config generation from schema
43c54b8 Pull default CLIEngineConfig into config file
10c0ea7 Add tests for createCoreRuleConfigs()
f032556 Add initial tests for SourceCodeObtain
aded766 Make options optional for getSourceCodeOfFiles
2480b42 Add more tests for SourceCodeObtain
67a8e75 Don’t export RuleConfigSet
9378f75 Account for new location of ecmaFeatures in config
3691dd4 Add some tests for config-initializer processAnswers()
3362eb9 Pass around Inquirer ui object explicitly
f8b1689 Rename `source-code-obtain` to `source-code-util`
3199afa Use Uppercase for Object and Registry in JSDoc
b39832a Install eslint-plugin-react before autoconfig runs
4c336fa Ask if the project is using ES6 modules
5e27d5c Pull npm installation into separate utility
b99d288 Add cwd to default cli options
ec526b3 Cleanups based on @gyandeeps’s review
1fcdc7b Stub out npm utility functions
36ed7e6 Fix bug when schema contains an enum and empty obj
dd64ffc Add initial tests for autoconfig
59a7247 Use logging utility
f486a5b Extend options from the defaults
bb2f63d Add more tests for autoconfig
f80d36e Disable autoconfig for JSX code, for now
f1a77e9 Remove timeout
c71bf08 Check package.json instead of installation status

Plus a few others ...
IanVS pushed a commit that referenced this issue Jan 27, 2016
This adds an option to `--init`, which will ask for a set of files to examine,
and then lint those files with various rule configuration settings.  Based on the
results of that linting, it will generate a configuration file which minimizes
the number of errors.

Rules in `eslint:recommended` will not be disabled, so they may still result in
erorrs, but all other rules will not give errors when linted against the same set
of files which was examined.

This also adds some utility functions, like `getSourceCodeOfFiles()` from
`lib/util/source-code-util.js`, utilities for working with npm (`lib/util/npm-util.js`)
and it extracts the default cli options into `conf/cli-options.js`.

At this time, this feature cannot be used for JSX code, due to #5007.

Commits which were squashed into this commit:

74869b5 Create autoconfig module
0d01ec3 Address comments so far
ebb9e56 Create helper for obtaining SourceCode from file(s)
c5215b6 Add autogenerate option to `—-init`
e00cb80 Add logic for collecting linting errors by rule config
ea614d0 Create config files with sorted keys
ab0a899 Add logic to choose “best” rule configs
1345e49 Do not initialize errorCount in registry to zero
5350fe5 Add a progress bar for reporting execution time.
7bec887 Use new parserOptions
06bedcc Remove manual rule blacklist
dc95669 Define ruleConfig and registryItem in JSDoc typedefs
2036ec5 Avoid populating registry upon construction
6581c18 Refactor and improve
f3290b8 Extend from “eslint:recommended”
7f39778 Doc cleanup
545a229 Break up Registry methods
aa7318b Split rule configuration from autoconfig
8a370cc Only disable rules which have no determined error-free config
9033b62 Do not disable eslint:recommended rules
a18b766 Add tests for config generation from schema
43c54b8 Pull default CLIEngineConfig into config file
10c0ea7 Add tests for createCoreRuleConfigs()
f032556 Add initial tests for SourceCodeObtain
aded766 Make options optional for getSourceCodeOfFiles
2480b42 Add more tests for SourceCodeObtain
67a8e75 Don’t export RuleConfigSet
9378f75 Account for new location of ecmaFeatures in config
3691dd4 Add some tests for config-initializer processAnswers()
3362eb9 Pass around Inquirer ui object explicitly
f8b1689 Rename `source-code-obtain` to `source-code-util`
3199afa Use Uppercase for Object and Registry in JSDoc
b39832a Install eslint-plugin-react before autoconfig runs
4c336fa Ask if the project is using ES6 modules
5e27d5c Pull npm installation into separate utility
b99d288 Add cwd to default cli options
ec526b3 Cleanups based on @gyandeeps’s review
1fcdc7b Stub out npm utility functions
36ed7e6 Fix bug when schema contains an enum and empty obj
dd64ffc Add initial tests for autoconfig
59a7247 Use logging utility
f486a5b Extend options from the defaults
bb2f63d Add more tests for autoconfig
f80d36e Disable autoconfig for JSX code, for now
f1a77e9 Remove timeout
c71bf08 Check package.json instead of installation status

Plus a few others ...
IanVS pushed a commit that referenced this issue Jan 29, 2016
This adds an option to `--init`, which will ask for a set of files to examine,
and then lint those files with various rule configuration settings.  Based on the
results of that linting, it will generate a configuration file which minimizes
the number of errors.

Rules in `eslint:recommended` will not be disabled, so they may still result in
erorrs, but all other rules will not give errors when linted against the same set
of files which was examined.

This also adds some utility functions, like `getSourceCodeOfFiles()` from
`lib/util/source-code-util.js`, utilities for working with npm (`lib/util/npm-util.js`)
and it extracts the default cli options into `conf/cli-options.js`.

At this time, this feature cannot be used for JSX code, due to #5007.

Commits which were squashed into this commit:

74869b5 Create autoconfig module
0d01ec3 Address comments so far
ebb9e56 Create helper for obtaining SourceCode from file(s)
c5215b6 Add autogenerate option to `—-init`
e00cb80 Add logic for collecting linting errors by rule config
ea614d0 Create config files with sorted keys
ab0a899 Add logic to choose “best” rule configs
1345e49 Do not initialize errorCount in registry to zero
5350fe5 Add a progress bar for reporting execution time.
7bec887 Use new parserOptions
06bedcc Remove manual rule blacklist
dc95669 Define ruleConfig and registryItem in JSDoc typedefs
2036ec5 Avoid populating registry upon construction
6581c18 Refactor and improve
f3290b8 Extend from “eslint:recommended”
7f39778 Doc cleanup
545a229 Break up Registry methods
aa7318b Split rule configuration from autoconfig
8a370cc Only disable rules which have no determined error-free config
9033b62 Do not disable eslint:recommended rules
a18b766 Add tests for config generation from schema
43c54b8 Pull default CLIEngineConfig into config file
10c0ea7 Add tests for createCoreRuleConfigs()
f032556 Add initial tests for SourceCodeObtain
aded766 Make options optional for getSourceCodeOfFiles
2480b42 Add more tests for SourceCodeObtain
67a8e75 Don’t export RuleConfigSet
9378f75 Account for new location of ecmaFeatures in config
3691dd4 Add some tests for config-initializer processAnswers()
3362eb9 Pass around Inquirer ui object explicitly
f8b1689 Rename `source-code-obtain` to `source-code-util`
3199afa Use Uppercase for Object and Registry in JSDoc
b39832a Install eslint-plugin-react before autoconfig runs
4c336fa Ask if the project is using ES6 modules
5e27d5c Pull npm installation into separate utility
b99d288 Add cwd to default cli options
ec526b3 Cleanups based on @gyandeeps’s review
1fcdc7b Stub out npm utility functions
36ed7e6 Fix bug when schema contains an enum and empty obj
dd64ffc Add initial tests for autoconfig
59a7247 Use logging utility
f486a5b Extend options from the defaults
bb2f63d Add more tests for autoconfig
f80d36e Disable autoconfig for JSX code, for now
f1a77e9 Remove timeout
c71bf08 Check package.json instead of installation status
86d6c09 Ignore existing eslint config files
3125f90 Use shelljs for execSync
764c291 Avoid changing process.cwd
9845060 Pass cwd to getSourceCodeOfFiles

Plus a few others ...
IanVS pushed a commit that referenced this issue Jan 29, 2016
This adds an option to `--init`, which will ask for a set of files to examine,
and then lint those files with various rule configuration settings.  Based on the
results of that linting, it will generate a configuration file which minimizes
the number of errors.

Rules in `eslint:recommended` will not be disabled, so they may still result in
erorrs, but all other rules will not give errors when linted against the same set
of files which was examined.

This also adds some utility functions, like `getSourceCodeOfFiles()` from
`lib/util/source-code-util.js`, utilities for working with npm (`lib/util/npm-util.js`)
and it extracts the default cli options into `conf/cli-options.js`.

At this time, this feature cannot be used for JSX code, due to #5007.

Commits which were squashed into this commit:

74869b5 Create autoconfig module
0d01ec3 Address comments so far
ebb9e56 Create helper for obtaining SourceCode from file(s)
c5215b6 Add autogenerate option to `—-init`
e00cb80 Add logic for collecting linting errors by rule config
ea614d0 Create config files with sorted keys
ab0a899 Add logic to choose “best” rule configs
1345e49 Do not initialize errorCount in registry to zero
5350fe5 Add a progress bar for reporting execution time.
7bec887 Use new parserOptions
06bedcc Remove manual rule blacklist
dc95669 Define ruleConfig and registryItem in JSDoc typedefs
2036ec5 Avoid populating registry upon construction
6581c18 Refactor and improve
f3290b8 Extend from “eslint:recommended”
7f39778 Doc cleanup
545a229 Break up Registry methods
aa7318b Split rule configuration from autoconfig
8a370cc Only disable rules which have no determined error-free config
9033b62 Do not disable eslint:recommended rules
a18b766 Add tests for config generation from schema
43c54b8 Pull default CLIEngineConfig into config file
10c0ea7 Add tests for createCoreRuleConfigs()
f032556 Add initial tests for SourceCodeObtain
aded766 Make options optional for getSourceCodeOfFiles
2480b42 Add more tests for SourceCodeObtain
67a8e75 Don’t export RuleConfigSet
9378f75 Account for new location of ecmaFeatures in config
3691dd4 Add some tests for config-initializer processAnswers()
3362eb9 Pass around Inquirer ui object explicitly
f8b1689 Rename `source-code-obtain` to `source-code-util`
3199afa Use Uppercase for Object and Registry in JSDoc
b39832a Install eslint-plugin-react before autoconfig runs
4c336fa Ask if the project is using ES6 modules
5e27d5c Pull npm installation into separate utility
b99d288 Add cwd to default cli options
ec526b3 Cleanups based on @gyandeeps’s review
1fcdc7b Stub out npm utility functions
36ed7e6 Fix bug when schema contains an enum and empty obj
dd64ffc Add initial tests for autoconfig
59a7247 Use logging utility
f486a5b Extend options from the defaults
bb2f63d Add more tests for autoconfig
f80d36e Disable autoconfig for JSX code, for now
f1a77e9 Remove timeout
c71bf08 Check package.json instead of installation status
86d6c09 Ignore existing eslint config files
3125f90 Use shelljs for execSync
764c291 Avoid changing process.cwd
9845060 Pass cwd to getSourceCodeOfFiles
f1c2176778f2c81390709e05ae848adb7cc6d976 Don’t split on commas

Plus a few others ...
@nzakas nzakas closed this as completed in 4fea752 Jan 29, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features feature This change adds a new feature to ESLint
Projects
None yet
Development

No branches or pull requests

4 participants