Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tagless-ember-components-codemod

Converts regular Ember.js components to tagName: '' components

readme

tagless-ember-components-codemod

Converts regular Ember.js components to tagName: '' components

This codemod is experimental and might break your app. Make sure to review the changes that it creates!

Usage

npx tagless-ember-components-codemod

Example

import Component from '@ember/component';

export default Component.extend({
  tagName: 'button',
  attributeBindings: ['disabled', 'disabled:aria-disabled'],
  classNames: ['custom-button'],
  classNameBindings: ['blue:blue:red'],
});
{{@text}}

will be migrated to:

import Component from '@ember/component';

export default Component.extend({
  tagName: '',
});
<button disabled={{disabled}} aria-disabled={{disabled}} class="custom-button {{if this.blue "blue" "red"}}">
  {{@text}}
</button>

Configuration

Paths

By default, tagless-ember-components-codemod will process components in the following folders relatively to project root:

app/components
addon/components

You may pass alternative paths or globs as arguments:

# process one component only
npx tagless-ember-components-codemod app/components/my-component.js

# process a component and all components under it's namespace
npx tagless-ember-components-codemod app/components/my-component.js app/components/my-component/

# process all components matching a glob
npx tagless-ember-components-codemod app/components/**/foo-*.js

Debug

Debug logging could be enabled by setting DEBUG environment variable to tagless-ember-components-codemod:

DEBUG=tagless-ember-components-codemod npx tagless-ember-components-codemod

Known Caveats

  • Due to the way jscodeshift works it sometimes removes empty lines between component properties, or adds new ones unexpectedly

  • Since click() and other event hooks don't work for tagless components, passing in something like @click=(action ...) also will not work anymore

  • Open Issues

License

This projects is released under the MIT License.

changelog

Changelog

Release (2024-10-01)

tagless-ember-components-codemod 1.0.0 (major)

:boom: Breaking Change

  • tagless-ember-components-codemod

:rocket: Enhancement

  • tagless-ember-components-codemod
    • #198 add basic support for mixins on native classes (@mansona)

:house: Internal

Committers: 1

v0.5.0 (2020-04-19)

:rocket: Enhancement

:bug: Bug Fix

Committers: 2

v0.4.0 (2020-02-25)

:boom: Breaking Change

:rocket: Enhancement

  • #59 Improve whitespace formatting of template code (@jelhan)
  • #44 Add support for native classes (@simonihmig)
  • #58 Add this. prefix to styleNamespace property (@lifeart)
  • #50 Add support for passing paths or glob patterns as CLI options (@jelhan)
  • #51 Add support for ariaRole property (@jelhan)

:bug: Bug Fix

:house: Internal

Committers: 4

v0.3.2 (2019-11-29)

:bug: Bug Fix

:house: Internal

Committers: 2

v0.3.1 (2019-11-29)

:rocket: Enhancement

:house: Internal

Committers: 2

v0.3.0 (2019-10-28)

:rocket: Enhancement

:bug: Bug Fix

  • #16 Skip components that use this.elementId (@Turbo87)

:memo: Documentation

  • #17 README: Add caveat about passed in event hooks (@Turbo87)

:house: Internal

Committers: 1

v0.2.0 (2019-10-26)

:rocket: Enhancement

:memo: Documentation

:house: Internal

Committers: 1

v0.1.0 (2019-10-10)

Initial release! 🎉