1.0.0 • Published 2 years ago

create-hashicorp-lint-setup-ember v1.0.0

Weekly downloads
-
License
Copyright HashiCo...
Repository
-
Last release
2 years ago

create-hashicorp-lint-setup-ember

Automatically sets up a linting configuration for an Ember.js app or addon using HashiCorp's eslint and ember-template-lint configs.

Usage

In the root folder of the app or addon you're working on, run the following command and follow the prompts:

yarn create hashicorp-lint-setup-ember

This will install the necessary dependencies and create or update the necessary files. Note that this does not install HashiCorp's prettier configuration, you will have to do that yourself as a separate step.

Adding globals

The .eslintrc.js file structure that is needed for this linting setup to work makes adding globals in the usual way difficult. Instead, if you want to add globals, create a file .eslintrc.globals.js that contains your eslint globals, which you can then require this file as needed in lower level .eslintrc.js files. For instance:

// .eslintrc.globals.js
module.exports = {
  globals: {
    MY_AWESOME_GLOBAL: true,
  },
};
// addon/.eslintrc.js
module.exports = {
  root: true,
  extends: [
    '@hashicorp/eslint-config-ember',
    require.resolve('../.eslintrc.globals.js'),
  ],
};
// tests/.eslintrc.js
module.exports = {
  root: true,
  extends: [
    '@hashicorp/eslint-config-ember/test',
    require.resolve('../.eslintrc.globals.js'),
  ],
};

What does it install?

It installs the following packages:

Moreover, it sets up various .eslintrc.js files and one .template-lintrc.js file, depending on your answers to the prompts.

If you're setting up an addon, the files generated will be:

.
├── .eslintrc.js [eslint-config-node]
├── .template-lintrc.js
├── addon
│   └── .eslintrc.js [eslint-config-ember]
├── app
│   └── .eslintrc.js [eslint-config-ember]
└── tests
    ├── .eslintrc.js [eslint-config-ember/test]
    └── dummy
        └── config
            └── .eslintrc.js [eslint-config-node]

If you're setting up an app, they will be:

.
├── .eslintrc.js [eslint-config-node]
├── .template-lintrc.js
├── app
│   └── .eslintrc.js [eslint-config-ember]
└── tests
    └── .eslintrc.js [eslint-config-ember/test]

If you've selected to use TypeScript, the files will be set up with their respective TypeScript configurations, rather than the standard vanilla JavaScript configurations.