ESLint 2.0.0 Wish List [$10]
Problem
As we are getting closer and closer to v1.0.0, it's time to start thinking about what a v2.0.0 would look like. Here are the things that have either come up recently or have been on my mind: - Autofix option - This has come up at least three times as a request. Originally I was pretty against it, but I'm starting to warm up to the idea. The idea is optionally fix certain types of issues instead of just reporting them. While this won't be possible for 100% of the rules, even a small percentage could make a big difference. - Autocreate config by looking at code - We need a way to make it easier to get started. Manually configuring over 100 rules is a painful process. It would be nice to be able to give ESLint a file and say "create me a config that matches the styles in this file". What other ideas do you have about big things we could tackle for 2.0.0? <bountysource-plugin> Did you help close this issue? Go claim the $10 bounty on Bountysource. </bountysource-plugin>
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Implement Autofix and Autocreate Config Features for ESLint 2.0.0
The current version of ESLint lacks features that allow automatic fixing of certain linting issues and the ability to generate configuration files based on existing code styles. This limitation makes it cumbersome for developers to adopt ESLint and maintain consistent coding standards across projects.
Awaiting Verification
Be the first to verify this fix
- 1
Design Autofix Feature
Identify the rules that can be automatically fixed and design an interface for the autofix feature. This will involve creating a mapping of rules to their corresponding fixable actions.
javascriptconst fixableRules = { 'no-unused-vars': fixUnusedVars, 'quotes': fixQuotes }; - 2
Implement Autofix Logic
Develop the logic to apply autofixes to the identified rules. This will require modifying the ESLint engine to include a new command-line option for autofixing.
basheslint --fix file.js - 3
Create Autocreate Config Feature
Develop a feature that analyzes a given JavaScript file and generates an ESLint configuration file based on the coding styles and rules used in that file. This will involve parsing the file and extracting style preferences.
javascriptconst config = generateConfigFromFile('example.js'); - 4
Integrate Features into ESLint CLI
Integrate both the autofix and autocreate config features into the ESLint command-line interface, allowing users to easily access these functionalities.
basheslint --autofix --autocreate-config file.js - 5
Testing and Validation
Create a suite of tests to validate the functionality of the new features. Ensure that the autofix feature correctly applies fixes and that the autocreate config feature generates accurate configurations.
bashnpm test
Validation
To confirm the fix worked, run ESLint on a sample JavaScript file with known linting issues and check if the autofix option resolves them. Additionally, provide a sample file to the autocreate config feature and verify that the generated config matches the expected coding styles.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep