custom-elements-manifest icon indicating copy to clipboard operation
custom-elements-manifest copied to clipboard

Add option to choose line endings within strings in custom-elements.json

Open xander-marjoram opened this issue 1 year ago • 0 comments

Checklist

  • [x] Did you run the analyzer with the --dev flag to get more information?
  • [ ] Did you create a minimal reproduction in the playground?

I did not create a minimal repro because it does not seem to support TypeScript Lit elements.

Expected behavior A clear and concise description of what you expected to happen.

I have a Lit component written in TypeScript. It has a property defined like so:

@property({ type: Object })
public leadingAction: {
    text: string;
};

When I run yarn cem analyze --litelement on Windows, the custom-elements.json file that is created contains the following:

{
    "kind": "field",
    "name": "leadingAction",
    "type": {
        "text": "{\r\n        text: string;\r\n    }"
    },
    "privacy": "public",
    "attribute": "leadingAction"
},

When my colleagues run the same command on MacOS, their string value of type.text contains the newline character \n instead of the carriage return \r\n.

I would like to be able to configure the CEM analyzer to output \n instead of \r\n to avoid unnecessary code conflicts/updates between runs on different operating systems.

In case it is useful, here is my custom-elements-manifest.config.mjs:

import { moduleFileExtensionsPlugin } from 'cem-plugin-module-file-extensions';

export default {
    globs: [
        '../../components/**/src/**/!(*.css).ts',
    ],
    exclude: [
        '../../**/*.d.ts',
        '../../**/*.d.js',
        '../../**/react.ts',
        '../../**/test/**',
        'node_modules/*',
        '../../**/node_modules/**',
        '../../**/pie-webc-testing/**',
    ],
    plugins: [moduleFileExtensionsPlugin()],
};

xander-marjoram avatar Jul 26 '23 13:07 xander-marjoram