• Stars
    star
    260
  • Rank 157,189 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An ESLint plugin that provides set of rules for Ember applications based on commonly known good practices.

eslint-plugin-ember

NPM version NPM downloads CI

An ESLint plugin that provides a set of rules for Ember applications based on commonly known good practices.

❗️Requirements

🚀 Usage

1. Install plugin

yarn add --dev eslint-plugin-ember

Or

npm install --save-dev eslint-plugin-ember

2. Modify your .eslintrc.js

// .eslintrc.js
module.exports = {
  plugins: ['ember'],
  extends: [
    'eslint:recommended',
    'plugin:ember/recommended' // or other configuration
  ],
  rules: {
    // override / enable optional rules
    'ember/no-replace-test-comments': 'error'
  }
};

🧰 Configurations

Name Description
recommended enables the recommended rules

🍟 Rules

💼 Configurations enabled in.
Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.

Components

Name                         Description 💼 🔧 💡
no-attrs-in-components disallow usage of this.attrs in components
no-attrs-snapshot disallow use of attrs snapshot in the didReceiveAttrs and didUpdateAttrs component hooks
no-classic-components enforce using Glimmer components
no-component-lifecycle-hooks disallow usage of "classic" ember component lifecycle hooks. Render modifiers or custom functional modifiers should be used instead.
no-on-calls-in-components disallow usage of on to call lifecycle hooks in components
require-tagless-components disallow using the wrapper element of a component

Computed Properties

Name                                                            Description 💼 🔧 💡
computed-property-getters enforce the consistent use of getters in computed properties
no-arrow-function-computed-properties disallow arrow functions in computed properties
no-assignment-of-untracked-properties-used-in-tracking-contexts disallow assignment of untracked properties that are used as computed property dependencies 🔧
no-computed-properties-in-native-classes disallow using computed properties in native classes
no-deeply-nested-dependent-keys-with-each disallow usage of deeply-nested computed property dependent keys with @each
no-duplicate-dependent-keys disallow repeating computed property dependent keys 🔧
no-incorrect-computed-macros disallow incorrect usage of computed property macros 🔧
no-invalid-dependent-keys disallow invalid dependent keys in computed properties 🔧
no-side-effects disallow unexpected side effects in computed properties
no-volatile-computed-properties disallow volatile computed properties
require-computed-macros require using computed property macros when possible 🔧
require-computed-property-dependencies require dependencies to be declared statically in computed properties 🔧
require-return-from-computed disallow missing return statements in computed properties
use-brace-expansion enforce usage of brace expansion in computed property dependent keys

Controllers

Name Description 💼 🔧 💡
alias-model-in-controller enforce aliasing model in controllers
avoid-using-needs-in-controllers disallow using needs in controllers
no-controllers disallow non-essential controllers

Deprecations

Name Description 💼 🔧 💡
closure-actions enforce usage of closure actions
new-module-imports enforce using "New Module Imports" from Ember RFC #176
no-array-prototype-extensions disallow usage of Ember's Array prototype extensions 🔧
no-deprecated-router-transition-methods enforce usage of router service transition methods 🔧
no-function-prototype-extensions disallow usage of Ember's function prototype extensions
no-implicit-injections enforce usage of implicit service injections 🔧
no-mixins disallow the usage of mixins
no-new-mixins disallow the creation of new mixins
no-observers disallow usage of observers
no-old-shims disallow usage of old shims for modules 🔧
no-string-prototype-extensions disallow usage of String prototype extensions

Ember Data

Name                           Description 💼 🔧 💡
no-empty-attrs disallow usage of empty attributes in Ember Data models
use-ember-data-rfc-395-imports enforce usage of @ember-data/ package imports instead ember-data 🔧

Ember Object

Name                                 Description 💼 🔧 💡
avoid-leaking-state-in-ember-objects disallow state leakage
no-get require using ES5 getters instead of Ember's get / getProperties functions 🔧
no-get-with-default disallow usage of the Ember's getWithDefault function 🔧
no-proxies disallow using array or object proxies
no-try-invoke disallow usage of the Ember's tryInvoke util
require-super-in-lifecycle-hooks require super to be called in lifecycle hooks 🔧
use-ember-get-and-set enforce usage of Ember.get and Ember.set 🔧

Ember Octane

Name                                 Description 💼 🔧 💡
classic-decorator-hooks enforce using correct hooks for both classic and non-classic classes
classic-decorator-no-classic-methods disallow usage of classic APIs such as get/set in classes that aren't explicitly decorated with @classic
no-actions-hash disallow the actions hash in components, controllers, and routes
no-classic-classes disallow "classic" classes in favor of native JS classes
no-ember-super-in-es-classes disallow use of this._super in ES class methods 🔧
no-empty-glimmer-component-classes disallow empty backing classes for Glimmer components
no-tracked-properties-from-args disallow creating @tracked properties from this.args

jQuery

Name Description 💼 🔧 💡
jquery-ember-run disallow usage of jQuery without an Ember run loop
no-global-jquery disallow usage of global jQuery object
no-jquery disallow any usage of jQuery

Miscellaneous

Name                                               Description 💼 🔧 💡
named-functions-in-promises enforce usage of named functions in promises
no-html-safe disallow the use of htmlSafe
no-incorrect-calls-with-inline-anonymous-functions disallow inline anonymous functions as arguments to debounce, once, and scheduleOnce
no-invalid-debug-function-arguments disallow usages of Ember's assert() / warn() / deprecate() functions that have the arguments passed in the wrong order.
no-restricted-property-modifications disallow modifying the specified properties 🔧
no-runloop disallow usage of @ember/runloop functions
require-fetch-import enforce explicit import for fetch()

Routes

Name                             Description 💼 🔧 💡
no-capital-letters-in-routes disallow routes with uppercased letters in router.js
no-controller-access-in-routes disallow routes from accessing the controller outside of setupController/resetController
no-private-routing-service disallow injecting the private routing service
no-shadow-route-definition enforce no route path definition shadowing
no-unnecessary-index-route disallow unnecessary index route definition
no-unnecessary-route-path-option disallow unnecessary usage of the route path option 🔧
route-path-style enforce usage of kebab-case (instead of snake_case or camelCase) in route paths 💡
routes-segments-snake-case enforce usage of snake_cased dynamic segments in routes

Services

Name                                      Description 💼 🔧 💡
no-implicit-service-injection-argument disallow omitting the injected service name argument 🔧
no-restricted-service-injections disallow injecting certain services under certain paths
no-unnecessary-service-injection-argument disallow unnecessary argument when injecting services 🔧
no-unused-services disallow unused service injections (see rule doc for limitations) 💡

Stylistic Issues

Name Description 💼 🔧 💡
order-in-components enforce proper order of properties in components 🔧
order-in-controllers enforce proper order of properties in controllers 🔧
order-in-models enforce proper order of properties in models 🔧
order-in-routes enforce proper order of properties in routes 🔧

Testing

Name                                       Description 💼 🔧 💡
no-current-route-name disallow usage of the currentRouteName() test helper
no-ember-testing-in-module-scope disallow use of Ember.testing in module scope
no-invalid-test-waiters disallow incorrect usage of test waiter APIs
no-legacy-test-waiters disallow the use of the legacy test waiter APIs
no-noop-setup-on-error-in-before disallows using no-op setupOnerror in before or beforeEach 🔧
no-pause-test disallow usage of the pauseTest helper in tests
no-replace-test-comments disallow 'Replace this with your real tests' comments in test files
no-restricted-resolver-tests disallow the use of patterns that use the restricted resolver in tests
no-settled-after-test-helper disallow usage of await settled() right after test helper that calls it internally 🔧
no-test-and-then disallow usage of the andThen test wait helper
no-test-import-export disallow importing of "-test.js" in a test file and exporting from a test file
no-test-module-for disallow usage of moduleFor, moduleForComponent, etc
no-test-support-import disallow importing of "test-support" files in production code.
no-test-this-render disallow usage of the this.render in tests, recommending to use @ember/test-helpers' render instead.
prefer-ember-test-helpers enforce usage of @ember/test-helpers methods over native window methods
require-valid-css-selector-in-test-helpers disallow using invalid CSS selectors in test helpers 🔧

🍻 Contribution Guide

If you have any suggestions, ideas, or problems, feel free to create an issue, but first please make sure your question does not repeat previous ones.

Creating a New Rule

  • Create an issue with a description of the proposed rule
  • Create files for the new rule:
    • lib/rules/new-rule.js (implementation, see no-proxies for an example)
    • docs/rules/new-rule.md (documentation, start from the template -- raw, rendered)
    • tests/lib/rules/new-rule.js (tests, see no-proxies for an example)
  • Run yarn update to automatically update the README and other files (and re-run this if you change the rule name or description)
  • Make sure your changes will pass CI by running:
    • yarn test
    • yarn lint (yarn lint:js --fix can fix many errors)
  • Create a PR and link the created issue in the description

Note that new rules should not immediately be added to the recommended configuration, as we only consider such breaking changes during major version updates.

🔓 License

See the LICENSE file for license rights and limitations (MIT).

More Repositories

1

ember-cli

The Ember.js command line utility.
JavaScript
3,261
star
2

ember-exam

Run your tests with randomization, splitting, and parallelization for beautiful tests.
JavaScript
286
star
3

ember-cli-update

Update Ember CLI projects
JavaScript
277
star
4

ember-twiddle

JSFiddle type thing for ember-cli style code
JavaScript
268
star
5

ember-ajax

Service for making AJAX requests in Ember applications
JavaScript
213
star
6

ember-page-title

Page title management for Ember.js Apps
JavaScript
188
star
7

ember-try

An ember-cli addon to test against multiple npm dependencies, such as ember and ember-data.
JavaScript
179
star
8

ember-fetch

HTML5 fetch polyfill from github wrapped and bundled for ember-cli users.
JavaScript
176
star
9

ember-cli-deprecation-workflow

JavaScript
165
star
10

ember-cli-mocha

Mocha and Chai tests for ember-cli applications
JavaScript
147
star
11

ember-cli-eslint

Ember CLI addon for linting Ember projects with ESLint
JavaScript
116
star
12

ember-new-output

Change history of new Ember-CLI apps
JavaScript
91
star
13

ember-resolver

JavaScript
87
star
14

broccoli-asset-rev

Broccoli plugin to add fingerprint checksums and CDN URLs to your assets
JavaScript
86
star
15

ember-rfc176-data

JSON data for Ember.js RFC #176
JavaScript
83
star
16

loader.js

minimal amd loader mostly stolen from wycats.
JavaScript
79
star
17

ember-cli-htmlbars

JavaScript
77
star
18

ember-template-imports

Template import support in Ember!
JavaScript
74
star
19

ember-cli-htmlbars-inline-precompile

📃 Precompile inline HTMLBars templates via ES6 tagged template strings
JavaScript
67
star
20

ember-cli-todos

JavaScript
67
star
21

babel-plugin-feature-flags

A babel transform for managing feature flags
JavaScript
57
star
22

ember-cli-app-version

Adds your app's version to Ember Inspector's Info tab
JavaScript
55
star
23

ember-cli-shims

DEPRECATED - ES6 import shims for Ember.js
JavaScript
46
star
24

ember-octane-blueprint

App and Addon blueprints for Ember Octane
JavaScript
46
star
25

rfcs

Archive of RFCs for changes to ember-cli (for current RFC repo see https://github.com/emberjs/rfcs)
45
star
26

ember-cli-babel-polyfills

Split-build polyfills for evergreen and legacy browsers
JavaScript
34
star
27

ember-cli-qunit

QUnit testing package for ember-cli applications
JavaScript
30
star
28

ember-compatibility-helpers

Helpers that allow you to write backwards compat Ember addons
JavaScript
24
star
29

ember-cli-version-checker

Dependency version checker for Ember CLI addons
JavaScript
24
star
30

broccoli-viz

library to read/parse and produce various visualizations of broccoli.
JavaScript
23
star
31

ember-cli-blueprint-test-helpers

Test helpers for testing ember-cli blueprints
JavaScript
23
star
32

ember-cli-terser

JavaScript minification for Ember-CLI
JavaScript
23
star
33

ember-cli-inject-live-reload

Ember CLI plugin that injects live-reload script into HTML content
JavaScript
22
star
34

ember-cli-chai

Chai assertions for Ember.js
JavaScript
21
star
35

babel-plugin-filter-imports

A babel transform for filtering out imports
JavaScript
18
star
36

broccoli-caching-writer

JavaScript
17
star
37

ember-addon-output

Change history of new Ember-CLI addons
JavaScript
16
star
38

core-object

JavaScript
16
star
39

babel-plugin-ember-modules-api-polyfill

Polyfill for Ember JS API
JavaScript
15
star
40

ember-load-initializers

JavaScript
14
star
41

console-ui

JavaScript
14
star
42

broccoli-es6modules

new es6 module transpiler
JavaScript
14
star
43

ember-export-application-global

JavaScript
14
star
44

babel-plugin-debug-macros

TypeScript
13
star
45

ember-cli.github.io

Our documentation site
SCSS
13
star
46

ember-router-generator

JavaScript
12
star
47

ember-welcome-page

Welcome page for Ember CLI applications
JavaScript
12
star
48

broccoli-terser-sourcemap

Broccoli filter to uglify with sourcemaps
JavaScript
10
star
49

broccoli-asset-rewrite

Broccoli plugin to rewrite a source tree from an asset map.
JavaScript
10
star
50

ember-cli-test-loader

JavaScript
10
star
51

ember-source-channel-url

JavaScript
10
star
52

stress-app

HTML
9
star
53

capture-exit

JavaScript
9
star
54

ember-next

A home for experiments that aim to become the defaults when running ember-new.
JavaScript
9
star
55

babel-plugin-htmlbars-inline-precompile

Babel plugin to replace tagged template strings with precompiled HTMLBars templates
JavaScript
9
star
56

broccoli-lint-eslint

Integrates JavaScript linting with ESLint as part of your Broccoli build pipeline.
JavaScript
8
star
57

blprnt

JavaScript
7
star
58

ember-cli-clean-css

CSS minification via clean-css for Ember CLI
JavaScript
6
star
59

exists-sync

Deprecated, please use fs.existsSync instead
JavaScript
6
star
60

ember-disable-prototype-extensions

Disables Ember's prototype extensions
JavaScript
6
star
61

silent-error

JavaScript
5
star
62

ember-cli-jshint

JSHint lint tests for your Ember CLI projects
JavaScript
5
star
63

create-ember-app

yarn create ember-app <name>
JavaScript
4
star
64

broccoli-middleware

Broccoli asset builder middleware
HTML
4
star
65

ember-cli-babili

JavaScript
4
star
66

ember-cli-update-codemods-manifest

Master list of codemods and their instructions used by ember-cli-update
JavaScript
4
star
67

amd-name-resolver

Algorithm for resolving AMD module names
JavaScript
3
star
68

ember-cli-string-utils

JavaScript
3
star
69

ember-cli-legacy-blueprints

Ember and Ember-Data specific blueprints for ember-cli projects not using the Ember and Ember-Data addons.
JavaScript
3
star
70

ember-cli-lodash-subset

JavaScript
2
star
71

ember-cli-default-packager

Default Packager for Ember CLI. More details in https://github.com/ember-cli/rfcs/pull/110.
TypeScript
2
star
72

codesandbox

Official Ember.js template for codesandbox.io
JavaScript
2
star
73

broccoli-amd-funnel

Funnel based on whether a module is AMD or not
JavaScript
1
star
74

broccoli-builder

JavaScript
1
star
75

calculate-cache-key-for-tree

ember-cli addon tree cache key builder
JavaScript
1
star
76

broccoli-funnel-reducer

JavaScript
1
star
77

app-blueprint-test

JavaScript
1
star
78

ember-cli-preprocess-registry

JavaScript
1
star
79

ember-cli-import-polyfill

Backports newer addon import API to older ember-cli versions.
JavaScript
1
star
80

node-modules-path

JavaScript
1
star
81

ember-build-utilities

A suite of build utilities for constructing Ember CLI build pipelines
JavaScript
1
star
82

ember-try-config

Config helper for ember-try
JavaScript
1
star
83

broccoli-config-replace

Simple templating using a config.json and regex patterns.
JavaScript
1
star
84

ember-cli-changelog

Tool used to generate changelogs for ember-cli.
JavaScript
1
star
85

create-ember-addon

yarn create ember-addon <name>
JavaScript
1
star