1.0.0 • Published 6 years ago

@bem-transform/ts-computed-name v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@bem-transform/ts-computed-name

Compute name of block and elem for BEM components.

Requirement

typescript >= 2.9.0

Installation

npm i -D @bem-transform/ts-computed-name

Configuration

This transform correctly work with ts-loader and awesome-typescript-loader.

const { computeClassBemName } = require('@bem-transform/ts-computed-name')

Need add this transform into getCustomTransformers in before section.

{
  test: /\.tsx?$/,
  use: [
    {
      loader: require.resolve('awesome-typescript-loader'),
      options: {
        getCustomTransformers: () => ({
          before: [
            computeClassBemName(options),
          ],
        }),
      },
    },
},

Options

PropertyTypeDefaultDescription
availableClassParentstring[]['Block', 'Elem']Will add properties only to classes who have the parents from list.
availibleBemNamebooleantrueWill add the properties of block and elem based on the location in the fs.
availibleDisplayNamebooleantrueWill add the static property of displayName based on the location in the fs. (Recommended add only in development mode for debugging)
namingstring'origin'naming convention that uses at the project, should be origin or react.
overrideExistingPropertiesbooleantrueOverrides existing properties block, elem and displayName.