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

feat(eslint-plugin-internal): add plugin-test-formatting rule #1821

Merged
merged 2 commits into from Mar 30, 2020

Commits on Mar 30, 2020

  1. feat(eslint-plugin-internal): add plugin-test-formatting rule

    The strings that are used for eslint plugins will not be checked for formatting.
    This can lead to diff noise as one contributor adjusts formatting, uses different quotes, etc.
    
    This rule just enforces the following:
    - all code samples are formatted with prettier
    - all single line tests do not use backticks
    - all multiline tests have:
      - no code on the first line
      - no code on the last line
      - the closing backtick indentation === property indentation
      - one of the following indentations:
        - no indentation at all
        - indentation of 1 + object indent
    
    examples of enforced style:
    ```ts
    ruleTester.run('foo', rule, {
      valid: [
        'const a = 1;',
        `
          const a = 1;
        `,
        `
    const a = 1;
        `,
        {
          code: 'const a = 1;',
        },
        {
          code: `
            const a = 1;
          `,
        },
        {
          code: `
    const a = 1;
          `,
        },
      ],
      invalid: [
        {
          code: 'const a = 1;',
        },
        {
          code: `
            const a = 1;
          `,
        },
        {
          code: `
    const a = 1;
          `,
        },
      ],
    });
    ```
    bradzacher committed Mar 30, 2020
    Copy the full SHA
    51d563a View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    392c76f View commit details
    Browse the repository at this point in the history