Sha256: 84d0682ecd8330a13b28b6f1e10a4beb35d6ebad1a0f284a67d2c8b56674cf21

Contents?: true

Size: 994 Bytes

Versions: 3

Compression:

Stored size: 994 Bytes

Contents

import { EMBER_GLIMMER_NAMED_ARGUMENTS } from '@ember/canary-features';
import { assert } from '@ember/debug';
import calculateLocationDisplay from '../system/calculate-location-display';
const RESERVED = ['@arguments', '@args', '@block', '@else'];
let isReserved, assertMessage;
export default function assertReservedNamedArguments(env) {
    let { moduleName } = env.meta;
    return {
        name: 'assert-reserved-named-arguments',
        visitor: {
            PathExpression({ original, loc }) {
                if (isReserved(original)) {
                    assert(`${assertMessage(original)} ${calculateLocationDisplay(moduleName, loc)}`);
                }
            },
        },
    };
}
if (EMBER_GLIMMER_NAMED_ARGUMENTS) {
    isReserved = name => RESERVED.indexOf(name) !== -1 || !!name.match(/^@[^a-z]/);
    assertMessage = name => `'${name}' is reserved.`;
}
else {
    isReserved = name => name[0] === '@';
    assertMessage = name => `'${name}' is not a valid path.`;
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.js
discourse-ember-source-3.5.1.1 dist/es/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-template-compiler/lib/plugins/assert-reserved-named-arguments.js