<commit_before>'use strict';

var assert = require('assert');
var gutil = require('gulp-util');
var lesshint = require('../');
var Stream = require('stream');

it('should check less files', function (cb) {
    var stream = lesshint();

    stream.on('error', function (error) {
        if (/spaceBeforeBrace/.test(error) && /spaceAfterPropertyColon/.test(error)) {
            assert(true);

            cb();
        }
    });

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/fixture.less',
        contents: new Buffer('.foo{ color: red; } \n')
    }));

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/fixture2.less',
        contents: new Buffer('.foo { color:red; } \n')
    }));

    stream.end();
});

it('should allow valid files', function (cb) {
    var stream = lesshint();

    stream.on('data', function () {});

    stream.on('error', function (error) {
        assert(false);
    });

    stream.on('end', cb);

    stream.write(new gutil.File({
        path: __dirname + '/fixture.less',
        contents: new Buffer('.foo { color: red; } \n')
    }));

    stream.end();
});

it('should load file specified in configPath', function (cb) {
    var stream = lesshint({
        configPath: './test/config.json'
    });

    stream.on('data', function () {});

    stream.on('error', function (error) {
        assert(false);

        cb();
    });

    stream.on('end', cb);

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/fixture.less',
        contents: new Buffer('.foo{ color: red; } \n')
    }));

    stream.end();
});

it('should ignore null files', function () {
    var stream = lesshint();

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/fixture.less',
        contents: null
    }));

    stream.end();
});

it('should ignore streams', function () {
    var stream = lesshint();

    assert.throws(function () {
        stream.write(new gutil.File({
            base: __dirname,
            path: __dirname + '/fixture.less',
            contents: new Stream()
        }));
    }, gutil.PluginError);

    stream.end();
});

it('should ignore excluded files', function () {
    var stream = lesshint({
        configPath: './test/config.json'
    });

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/exclude.less',
        contents: new Buffer('.foo{ color: red; } \n')
    }));

    stream.end();
});<commit_msg>Update test data for new lesshint rules<commit_after>'use strict';

var assert = require('assert');
var gutil = require('gulp-util');
var lesshint = require('../');
var Stream = require('stream');

it('should check less files', function (cb) {
    var stream = lesshint();

    stream.on('error', function (error) {
        if (/spaceBeforeBrace/.test(error) && /spaceAfterPropertyColon/.test(error)) {
            assert(true);

            cb();
        }
    });

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/fixture.less',
        contents: new Buffer('.foo{\ncolor: red;\n}\n')
    }));

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/fixture2.less',
        contents: new Buffer('.foo {\ncolor:red;\n}\n')
    }));

    stream.end();
});

it('should allow valid files', function (cb) {
    var stream = lesshint();

    stream.on('data', function () {});

    stream.on('error', function (error) {
        assert(false);
    });

    stream.on('end', cb);

    stream.write(new gutil.File({
        path: __dirname + '/fixture.less',
        contents: new Buffer('.foo {\ncolor: red;\n}\n')
    }));

    stream.end();
});

it('should load file specified in configPath', function (cb) {
    var stream = lesshint({
        configPath: './test/config.json'
    });

    stream.on('data', function () {});

    stream.on('error', function (error) {
        assert(false);

        cb();
    });

    stream.on('end', cb);

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/fixture.less',
        contents: new Buffer('.foo {\ncolor: red;\n}\n')
    }));

    stream.end();
});

it('should ignore null files', function () {
    var stream = lesshint();

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/fixture.less',
        contents: null
    }));

    stream.end();
});

it('should ignore streams', function () {
    var stream = lesshint();

    assert.throws(function () {
        stream.write(new gutil.File({
            base: __dirname,
            path: __dirname + '/fixture.less',
            contents: new Stream()
        }));
    }, gutil.PluginError);

    stream.end();
});

it('should ignore excluded files', function () {
    var stream = lesshint({
        configPath: './test/config.json'
    });

    stream.write(new gutil.File({
        base: __dirname,
        path: __dirname + '/exclude.less',
        contents: new Buffer('.foo{\ncolor: red;\n}\n')
    }));

    stream.end();
});
{'fraction_non_alphanumeric': 0.1795374362994904, 'fraction_numerical': 0.0003920031360250882, 'mean_word_length': 2.320104098893949, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1143554', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1536, 'n_words': 367}