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

Add meta.fixable property to each rule #6181

Merged
merged 3 commits into from
Jun 28, 2022

Commits on Jun 28, 2022

  1. Add meta.fixable property to each rule

    This commit add a new property `meta.fixable` to each rule.
    Also, this fixes inaccurate docs about autofix.
    
    ---
    
    I used the following script for [`jscodeshift`](https://github.com/facebook/jscodeshift) to perform the task easily.
    (though I needed to fix a few files manually)
    
    ```js
    /**
     * @type {import('jscodeshift').Transform}
     */
    module.exports = function transform(fileInfo, api) {
    	const j = api.jscodeshift;
    	const root = j(fileInfo.source);
    
    	root.findVariableDeclarators('meta').forEach((decl) => {
    		if (root.find(j.Identifier, { name: 'fix' }).length > 0) {
    			decl.node.init.properties.push(j.property('init', j.identifier('fixable'), j.literal(true)));
    		}
    	});
    
    	return root.toSource();
    };
    ```
    
    ```console
    $ npm i -D jscodeshift @types/jscodeshift
    ...
    
    $ npx jscodeshift lib/rules/*/index.js
    ...
    ```
    ybiquitous committed Jun 28, 2022
    Configuration menu
    Copy the full SHA
    0cb4795 View commit details
    Browse the repository at this point in the history
  2. Trim node: prefix

    ybiquitous committed Jun 28, 2022
    Configuration menu
    Copy the full SHA
    6b4afc9 View commit details
    Browse the repository at this point in the history
  3. Fix file path

    ybiquitous committed Jun 28, 2022
    Configuration menu
    Copy the full SHA
    dc36bf7 View commit details
    Browse the repository at this point in the history