Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 1018 Bytes

no-object-define.md

File metadata and controls

54 lines (39 loc) · 1018 Bytes

Disallow use of Simple Name/Value Pairs form of define (no-object-define)

Rule Details

This rule aims to prevent usage of plain object module definitions.

The following patterns are considered warnings:

define({
    a: 'foo',
    b: 'bar'
});

define('path/to/baz', {
    a: 'foo',
    b: 'bar'
});

The following patterns are not warnings:

// Definition Function
define(function () {
    /* ... */
});

// Definition Function with Dependencies
define(['path/to/foo', 'path/to/bar'], function (foo, bar) {
    /* ... */
});

// Named Module with Dependencies
define('path/to/baz', ['path/to/foo'], function (foo) {
    /* ... */
});

// Simplified CommonJS Wrapper
define(function (require) {
    var foo = require('path/to/foo'),
        bar = require('path/to/bar');

    /* ... */
});

When Not To Use It

If you want to use plain object modules, then it is safe to disable this rule.

Further Reading