Skip to content

Prettier keeps breaking .babelrc #4636

@bradennapier

Description

@bradennapier

Hard to do the playground - but prettier is completely breaking my system because it makes .babelrc invalid

Input (.babelrc):

{
    "presets": [
      "@babel/preset-flow",
      [
        "@babel/preset-env",
        {
          "cacheDirectory": true,
          "useBuiltIns": "usage",
          "targets": {
            "node": "8.10"
          }
        }
      ],
      ["@babel/preset-stage-0", {
        "decoratorsLegacy": true
      }]
    ],
    "plugins": ["lodash", "@babel/plugin-codemod-optional-catch-binding"]
  }

Output

{
  presets: [
    '@babel/preset-flow',
    [
      '@babel/preset-env',
      {
        cacheDirectory: true,
        useBuiltIns: 'usage',
        targets: {
          node: '8.10',
        },
      },
    ],
    [
      '@babel/preset-stage-3',
      {
        decoratorsLegacy: true,
      },
    ],
  ],
  plugins: ['lodash', '@babel/plugin-codemod-optional-catch-binding'],
}

Obviously .babelrc is not a js file and it is not indicated as so yet it appears to assume it is. This only happens specifically for .babelrc - not sure why it assuming its js?

In babel 7 they optionally will allow .babelrc.js but this does not have such a file extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.type:questionQuestions and support requests. Please use Stack Overflow for them, not the issue tracker.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions