open-wc / custom-elements-manifest

Custom Elements Manifest is a file format that describes custom elements in your project.
https://custom-elements-manifest.open-wc.org/
226 stars 37 forks source link

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

Open xander-marjoram opened 11 months ago

xander-marjoram commented 11 months ago

Checklist

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()],
};