<commit_before>import template from '../util/moduleTemplate';
import globals from '../util/globals';
import arrayOfStrings from '../util/arrayOfStrings';
import generateProgram from './program';
import requireModules from './requireModules';

export default () => {
    const tmpl = template(`
    export default function cssValues (property, value) {
        if (typeof value === 'string') {
            value = valueParser(value);
        }
        const first = value.nodes[0];
        if (value.nodes.length === 1 && (isKeyword(first, cssGlobals) || isVariable(first))) {
            return true;
        }
        return validators.some(validator => {
            if (!~validator.properties.indexOf(property)) {
                return;
            }
            return validator.fn(value);
        });
    }
    `);

    return generateProgram([
        requireModules({
            identifier: 'isKeyword',
            module: './validators/isKeyword',
        }, {
            identifier: 'isVariable',
            module: './validators/isVariable',
        }, {
            identifier: 'validators',
            module: './properties/index',
        }, {
            identifier: 'valueParser',
            module: 'postcss-value-parser',
        }),
        template(`const cssGlobals = INJECT;`)({
            INJECT: arrayOfStrings(globals),
        }),
        tmpl(),
    ]);
};<commit_msg>Replace template with ast.<commit_after>import * as t from 'babel-types';
import template from '../util/moduleTemplate';
import globals from '../util/globals';
import arrayOfStrings from '../util/arrayOfStrings';
import generateProgram from './program';
import requireModules from './requireModules';

export default () => {
    const tmpl = template(`
    export default function cssValues (property, value) {
        if (typeof value === 'string') {
            value = valueParser(value);
        }
        const first = value.nodes[0];
        if (value.nodes.length === 1 && (isKeyword(first, cssGlobals) || isVariable(first))) {
            return true;
        }
        return validators.some(validator => {
            if (!~validator.properties.indexOf(property)) {
                return;
            }
            return validator.fn(value);
        });
    }
    `);

    return generateProgram([
        requireModules({
            identifier: 'isKeyword',
            module: './validators/isKeyword',
        }, {
            identifier: 'isVariable',
            module: './validators/isVariable',
        }, {
            identifier: 'validators',
            module: './properties/index',
        }, {
            identifier: 'valueParser',
            module: 'postcss-value-parser',
        }),
        t.variableDeclaration('const', [
            t.variableDeclarator(
                t.identifier('cssGlobals'),
                arrayOfStrings(globals)
            ),
        ]),
        tmpl(),
    ]);
};
{'fraction_non_alphanumeric': 0.13647219379051517, 'fraction_numerical': 0.001364721937905152, 'mean_word_length': 1.9000989119683482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5183506', 'n_tokens_mistral': 741, 'n_tokens_neox': 748, 'n_words': 167}