From d51c156f6113224b2e019ad81da7c2a592598c5b Mon Sep 17 00:00:00 2001 From: Cory Loken Date: Wed, 6 Nov 2024 10:03:01 -0500 Subject: [PATCH] Apply lint fixes. Ignore some files that can be addressed in a follow up pr --- .prettierrc.js => .prettierrc.cjs | 0 addon/utils/get-messages.js | 4 +- addon/utils/handle-multiple-validations.js | 8 +-- addon/utils/to-date.js | 3 +- addon/utils/validation-errors.js | 6 +-- eslint.config.mjs | 53 +++++++++++++++++++ node-test/.eslintrc.js | 16 ------ node-test/blueprints/validator-test.js | 6 +-- .../components/address-book-test.js | 2 +- .../components/validation-errors-test.js | 18 +++---- tests/unit/helpers/changeset-test.js | 28 +++++----- tests/unit/utils/get-messages-test.js | 2 +- tests/unit/utils/validation-errors-test.js | 18 +++---- tests/unit/validators/confirmation-test.js | 12 ++--- tests/unit/validators/date-test.js | 48 ++++++++--------- tests/unit/validators/exclusion-test.js | 8 +-- tests/unit/validators/format-test.js | 14 ++--- tests/unit/validators/inclusion-test.js | 12 ++--- tests/unit/validators/length-test.js | 16 +++--- tests/unit/validators/number-test.js | 40 +++++++------- tests/unit/validators/presence-test.js | 28 +++++----- 21 files changed, 189 insertions(+), 153 deletions(-) rename .prettierrc.js => .prettierrc.cjs (100%) create mode 100644 eslint.config.mjs delete mode 100644 node-test/.eslintrc.js diff --git a/.prettierrc.js b/.prettierrc.cjs similarity index 100% rename from .prettierrc.js rename to .prettierrc.cjs diff --git a/addon/utils/get-messages.js b/addon/utils/get-messages.js index 473ec4c..53ab7fd 100644 --- a/addon/utils/get-messages.js +++ b/addon/utils/get-messages.js @@ -22,7 +22,7 @@ let cachedRef = null; */ export default function getMessages( moduleMap = requirejs.entries, - useCache = true + useCache = true, ) { let messagesModule = defaultMessages; @@ -36,7 +36,7 @@ export default function getMessages( // Merge the user specified messages with the defaults messagesModule = withDefaults( requireModule(moduleKey).default, - messagesModule + messagesModule, ); } diff --git a/addon/utils/handle-multiple-validations.js b/addon/utils/handle-multiple-validations.js index 1a6a8b8..643613d 100644 --- a/addon/utils/handle-multiple-validations.js +++ b/addon/utils/handle-multiple-validations.js @@ -13,7 +13,7 @@ import { isPromise } from 'validated-changeset'; */ function handleValidations(validations = []) { let rejectedValidations = emberArray(validations).reject( - (validation) => typeOf(validation) === 'boolean' && validation + (validation) => typeOf(validation) === 'boolean' && validation, ); return rejectedValidations.length === 0 || rejectedValidations; @@ -34,12 +34,12 @@ function handleValidations(validations = []) { */ export default function handleMultipleValidations( validators, - { key, newValue, oldValue, changes, content } + { key, newValue, oldValue, changes, content }, ) { let validations = emberArray( validators.map((validator) => - validator(key, newValue, oldValue, changes, content) - ) + validator(key, newValue, oldValue, changes, content), + ), ); if (emberArray(validations).any(isPromise)) { diff --git a/addon/utils/to-date.js b/addon/utils/to-date.js index 974d53b..6e9ea9d 100644 --- a/addon/utils/to-date.js +++ b/addon/utils/to-date.js @@ -23,9 +23,8 @@ export default function toDate(argument) { (typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined' ) { - // eslint-disable-next-line no-console console.warn('Please use `Date.parse` to parse strings.'); - // eslint-disable-next-line no-console + console.warn(new Error().stack); } return new Date(NaN); diff --git a/addon/utils/validation-errors.js b/addon/utils/validation-errors.js index 545f54c..eaf2055 100644 --- a/addon/utils/validation-errors.js +++ b/addon/utils/validation-errors.js @@ -34,7 +34,7 @@ export default function buildMessage(key, result) { let builtMessage = message(key, type, value, context); assert( 'Custom message function must return a string', - typeof builtMessage === 'string' + typeof builtMessage === 'string', ); return builtMessage; @@ -42,12 +42,12 @@ export default function buildMessage(key, result) { return messages.formatMessage( message, - Object.assign({ description }, context) + Object.assign({ description }, context), ); } return messages.formatMessage( message, - Object.assign({ description }, context) + Object.assign({ description }, context), ); } diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..beb7fde --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,53 @@ +// eslint.config.mjs + +import { FlatCompat } from '@eslint/eslintrc'; +import emberPlugin from 'eslint-plugin-ember'; +import prettierPlugin from 'eslint-plugin-prettier'; +import js from '@eslint/js'; // Import ESLint core configs +import globals from 'globals'; // Import globals + +const compat = new FlatCompat({ + baseDirectory: import.meta.url, + resolvePluginsRelativeTo: import.meta.url, + recommendedConfig: js.configs.recommended, // Provide recommendedConfig +}); + +export default [ + { + files: ['**/*.js'], + languageOptions: { + ecmaVersion: 'latest', + sourceType: 'module', // Ensure ES module parsing + globals: { + ...globals.browser, + }, + }, + plugins: { + ember: emberPlugin, + prettier: prettierPlugin, + }, + rules: {}, + }, + // Extend configurations using FlatCompat + ...compat.extends( + 'eslint:recommended', + 'plugin:ember/recommended', + 'plugin:prettier/recommended', + ), + { + ignores: [ + 'node_modules/', + 'dist/', + 'blueprints', + '.prettierrc.cjs', + '.template-lintrc.js', + 'config/ember-try.js', + 'ember-cli-build.js', + 'index.js', + 'node-test/', + 'config/environment.js', + 'tests/dummy/', + 'testem.js', + ], + }, +]; diff --git a/node-test/.eslintrc.js b/node-test/.eslintrc.js deleted file mode 100644 index ce334df..0000000 --- a/node-test/.eslintrc.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -module.exports = { - env: { - mocha: true, - }, - rules: { - 'node/no-unpublished-require': [ - 'error', - { - // ESLint complaints but it's just devDependencies and used only in tests. - allowModules: ['ember-cli-blueprint-test-helpers'], - }, - ], - }, -}; diff --git a/node-test/blueprints/validator-test.js b/node-test/blueprints/validator-test.js index 846a51f..eed4206 100644 --- a/node-test/blueprints/validator-test.js +++ b/node-test/blueprints/validator-test.js @@ -16,15 +16,15 @@ describe('Acceptance: ember generate and destroy validator', function () { return emberNew().then(() => emberGenerateDestroy(args, (file) => { expect(file('app/validators/is-positive.js')).to.contain( - 'export default function validateIsPositive(/* options = {} */) {\n' + 'export default function validateIsPositive(/* options = {} */) {\n', ); expect(file('tests/unit/validators/is-positive-test.js')) .to.contain( - "import validateIsPositive from 'my-app/validators/is-positive';" + "import validateIsPositive from 'my-app/validators/is-positive';", ) .to.contain("module('Unit | Validator | is-positive');") .to.contain('assert.ok(validateIsPositive());'); - }) + }), ); }); }); diff --git a/tests/integration/components/address-book-test.js b/tests/integration/components/address-book-test.js index 4317ebb..9f65db5 100644 --- a/tests/integration/components/address-book-test.js +++ b/tests/integration/components/address-book-test.js @@ -13,7 +13,7 @@ module('Integration | Component | address-book', function (hooks) { return Promise.resolve(); }; await render( - hbs`` + hbs``, ); await fillIn('#address-book-name', 'abcdef'); diff --git a/tests/integration/components/validation-errors-test.js b/tests/integration/components/validation-errors-test.js index 9850757..1556f54 100644 --- a/tests/integration/components/validation-errors-test.js +++ b/tests/integration/components/validation-errors-test.js @@ -50,7 +50,7 @@ module('Integration | Components | validation errors', function (hooks) { assert.strictEqual( find('ul.lastNameErrors li').textContent.trim(), '[CUSTOM] Last name is too short (minimum is 2 characters)', - 'has last name errors' + 'has last name errors', ); assert.notOk(find('ul.ageErrors'), 'has no age errors'); @@ -58,11 +58,11 @@ module('Integration | Components | validation errors', function (hooks) { assert.ok( find('ul.firstNameErrors li'), - 'has first name errors after last name input' + 'has first name errors after last name input', ); assert.notOk( find('ul.lastNameErrors'), - 'has no last name errors after input' + 'has no last name errors after input', ); assert.notOk(find('ul.ageErrors'), 'has no age errors'); @@ -70,11 +70,11 @@ module('Integration | Components | validation errors', function (hooks) { assert.ok( find('ul.firstNameErrors li'), - 'has first name errors after last name input' + 'has first name errors after last name input', ); assert.notOk( find('ul.lastNameErrors'), - 'has no last name errors after input' + 'has no last name errors after input', ); assert.notOk(find('ul.ageErrors'), 'has no age errors after input'); @@ -82,11 +82,11 @@ module('Integration | Components | validation errors', function (hooks) { assert.ok( find('ul.firstNameErrors li'), - 'has first name errors after last name input' + 'has first name errors after last name input', ); assert.notOk( find('ul.lastNameErrors'), - 'has no last name errors after input' + 'has no last name errors after input', ); assert.ok(find('ul.ageErrors'), 'has age errors after input'); }); @@ -133,7 +133,7 @@ module('Integration | Components | validation errors', function (hooks) { assert.strictEqual( find('ul.stateWiErrors li').textContent.trim(), '[CUSTOM] State wi is too short (minimum is 2 characters)', - 'has last name errors' + 'has last name errors', ); await fillIn('input.state-wi', 'bc'); @@ -142,7 +142,7 @@ module('Integration | Components | validation errors', function (hooks) { assert.strictEqual( find('ul.stateNyErrors li').textContent.trim(), '[CUSTOM] State ny is too short (minimum is 2 characters)', - 'has last name errors' + 'has last name errors', ); assert.notOk(find('ul.stateWiErrors'), 'has no wi errors after input'); }); diff --git a/tests/unit/helpers/changeset-test.js b/tests/unit/helpers/changeset-test.js index 72cac16..af5ba3a 100644 --- a/tests/unit/helpers/changeset-test.js +++ b/tests/unit/helpers/changeset-test.js @@ -39,7 +39,7 @@ module('Unit | Helper | changeset', function () { ]); assert.ok( changesetInstance.get('isInvalid'), - 'should be invalid with wrong length first name' + 'should be invalid with wrong length first name', ); changesetInstance.set('firstName', ''); @@ -49,24 +49,24 @@ module('Unit | Helper | changeset', function () { ]); assert.ok( changesetInstance.get('isInvalid'), - 'should be invalid with blank first name' + 'should be invalid with blank first name', ); changesetInstance.set('lastName', ''); assert.deepEqual( changesetInstance.get('error').lastName.validation, - "[CUSTOM] Last name can't be blank" + "[CUSTOM] Last name can't be blank", ); assert.ok( changesetInstance.get('isInvalid'), - 'should be invalid with blank last name' + 'should be invalid with blank last name', ); changesetInstance.set('firstName', 'Jim'); changesetInstance.set('lastName', 'Bob'); assert.ok( changesetInstance.get('isValid'), - 'should be valid after setting valid first and last names' + 'should be valid after setting valid first and last names', ); }); @@ -91,7 +91,7 @@ module('Unit | Helper | changeset', function () { assert.deepEqual( JSON.parse(JSON.stringify(changesetInstance.get('error').email)), expectedError, - 'email should error' + 'email should error', ); changesetInstance.set('username', 'jimbob'); @@ -99,7 +99,7 @@ module('Unit | Helper | changeset', function () { assert.deepEqual( changesetInstance.get('change').username, 'jimbob', - 'should set username' + 'should set username', ); changesetInstance.set('username', 'foo@bar.com'); @@ -108,7 +108,7 @@ module('Unit | Helper | changeset', function () { assert.deepEqual( JSON.parse(JSON.stringify(changesetInstance.get('error').username)), expectedError, - 'username should error' + 'username should error', ); }); @@ -127,13 +127,13 @@ module('Unit | Helper | changeset', function () { changesetInstance.set('firstName', 'Herp'); assert.ok( changesetInstance.get('isValid'), - 'should be valid if content is passed into validator' + 'should be valid if content is passed into validator', ); changesetInstance.set('lastName', 'McDerpface'); assert.ok( changesetInstance.get('isValid'), - 'should be valid if content is passed into validator' + 'should be valid if content is passed into validator', ); }); @@ -152,18 +152,18 @@ module('Unit | Helper | changeset', function () { changesetInstance.validate().then(() => { assert.deepEqual( changesetInstance.get('error').firstName.validation, - "[CUSTOM] First name can't be blank" + "[CUSTOM] First name can't be blank", ); assert.ok( changesetInstance.get('isInvalid'), - 'should be invalid with wrong length first name' + 'should be invalid with wrong length first name', ); changesetInstance.set('firstName', 'Jim'); changesetInstance.set('lastName', 'Bob'); assert.ok( changesetInstance.get('isValid'), - 'should be valid after setting valid first and last names' + 'should be valid after setting valid first and last names', ); }); }); @@ -183,7 +183,7 @@ module('Unit | Helper | changeset', function () { }); assert.ok( changesetInstance.get('_options').skipValidate, - 'option should have been passed through' + 'option should have been passed through', ); changesetInstance.set('firstName', ''); diff --git a/tests/unit/utils/get-messages-test.js b/tests/unit/utils/get-messages-test.js index 70a5467..aa49806 100644 --- a/tests/unit/utils/get-messages-test.js +++ b/tests/unit/utils/get-messages-test.js @@ -20,7 +20,7 @@ module('Unit | Utility | get messages', function () { assert.deepEqual( getMessages(dummyModuleMap, false), defaultMessages, - 'loads the correct module' + 'loads the correct module', ); }); }); diff --git a/tests/unit/utils/validation-errors-test.js b/tests/unit/utils/validation-errors-test.js index 3dad17b..192e6b1 100644 --- a/tests/unit/utils/validation-errors-test.js +++ b/tests/unit/utils/validation-errors-test.js @@ -16,16 +16,16 @@ module('Unit | Utility | validation errors', function () { test('#formatMessage formats a blank message', function (assert) { assert.strictEqual( messages.formatMessage('{foo} is {bar}', { foo: 'foo', bar: 'bar' }), - 'foo is bar' + 'foo is bar', ); }); test('#buildMessage builds a validation message', function (assert) { assert.notStrictEqual( buildMessage('firstName', { type: 'invalid' }).indexOf( - 'First name is invalid' + 'First name is invalid', ), - -1 + -1, ); }); @@ -40,7 +40,7 @@ module('Unit | Utility | validation errors', function () { }, }), "First name can't be equal to foo", - 'Built message is generated correctly' + 'Built message is generated correctly', ); }); @@ -49,12 +49,12 @@ module('Unit | Utility | validation errors', function () { assert.strictEqual( buildMessage('firstName', { type: 'present' }), "First name can't be blank", - '"present" message is correct' + '"present" message is correct', ); assert.strictEqual( buildMessage('firstName', { type: 'blank' }), 'First name must be blank', - '"blank" message is correct' + '"blank" message is correct', ); }); @@ -77,7 +77,7 @@ module('Unit | Utility | validation errors', function () { context: { message, foo: 'foo' }, }), 'some test message', - 'correct custom error message is returned' + 'correct custom error message is returned', ); }); @@ -92,7 +92,7 @@ module('Unit | Utility | validation errors', function () { assert.notStrictEqual( typeof result, 'string', - 'the return value is an object' + 'the return value is an object', ); let { message, @@ -119,7 +119,7 @@ module('Unit | Utility | validation errors', function () { assert.notStrictEqual( typeof result, 'string', - 'the return value is an object' + 'the return value is an object', ); let { message, diff --git a/tests/unit/validators/confirmation-test.js b/tests/unit/validators/confirmation-test.js index d7e1745..d336a77 100644 --- a/tests/unit/validators/confirmation-test.js +++ b/tests/unit/validators/confirmation-test.js @@ -11,15 +11,15 @@ module('Unit | Validator | confirmation', function () { assert.strictEqual( validator(key, undefined, undefined, changes), - buildMessage(key, { type: 'confirmation', context: opts }) + buildMessage(key, { type: 'confirmation', context: opts }), ); assert.strictEqual( validator(key, null, undefined, changes), - buildMessage(key, { type: 'confirmation', context: opts }) + buildMessage(key, { type: 'confirmation', context: opts }), ); assert.strictEqual( validator(key, '', undefined, changes), - buildMessage(key, { type: 'confirmation', context: opts }) + buildMessage(key, { type: 'confirmation', context: opts }), ); assert.true(validator(key, '1234567', undefined, changes)); }); @@ -36,7 +36,7 @@ module('Unit | Validator | confirmation', function () { assert.strictEqual( validator(key, undefined, undefined, changes), 'Password confirmation is not equal to password', - 'custom message string is generated correctly' + 'custom message string is generated correctly', ); }); @@ -61,7 +61,7 @@ module('Unit | Validator | confirmation', function () { assert.strictEqual( validator(key, 'testValue', undefined, changes), 'some test message', - 'custom message function is returned correctly' + 'custom message function is returned correctly', ); }); @@ -85,7 +85,7 @@ test('It looks for default values as well as "changes" values', function (assert assert.strictEqual( validator(key, 'foo', undefined, {}, content), - buildMessage(key, { type: 'confirmation', context: opts }) + buildMessage(key, { type: 'confirmation', context: opts }), ); assert.true(validator(key, password, undefined, {}, content)); }); diff --git a/tests/unit/validators/date-test.js b/tests/unit/validators/date-test.js index 49bf402..868578f 100644 --- a/tests/unit/validators/date-test.js +++ b/tests/unit/validators/date-test.js @@ -19,17 +19,17 @@ module('Unit | Validator | date', function () { value: 'not a date', context: options, }), - 'result: [CUSTOM] Birth date must be a valid date' + 'result: [CUSTOM] Birth date must be a valid date', ); assert.strictEqual( validator(key, NaN), buildMessage(key, { type: 'date', value: NaN, context: options }), - 'result: NaN is not allowed' + 'result: NaN is not allowed', ); assert.strictEqual( validator(key, {}), buildMessage(key, { type: 'date', value: {}, context: options }), - 'result: empty object is not allowed' + 'result: empty object is not allowed', ); }); @@ -49,7 +49,7 @@ module('Unit | Validator | date', function () { validator = validateDate(options); assert.true( validator(key, Date.parse(startDate)), - 'accepts milliseconds with both args' + 'accepts milliseconds with both args', ); }); @@ -66,7 +66,7 @@ module('Unit | Validator | date', function () { value: 'pity a fool', context: options, }), - 'result: [CUSTOM] Test date must be a valid date' + 'result: [CUSTOM] Test date must be a valid date', ); }); @@ -83,7 +83,7 @@ module('Unit | Validator | date', function () { value: 'not a date', context: options, }), - 'result: [CUSTOM] Test date must be a valid date' + 'result: [CUSTOM] Test date must be a valid date', ); assert.strictEqual( validator(key, null), @@ -92,7 +92,7 @@ module('Unit | Validator | date', function () { value: 'not a date', context: options, }), - 'result: [CUSTOM] Test date must be a valid date' + 'result: [CUSTOM] Test date must be a valid date', ); assert.strictEqual( validator(key, undefined), @@ -101,7 +101,7 @@ module('Unit | Validator | date', function () { value: 'not a date', context: options, }), - 'result: [CUSTOM] Test date must be a valid date' + 'result: [CUSTOM] Test date must be a valid date', ); assert.strictEqual( validator(key, '1992-03-30'), @@ -110,7 +110,7 @@ module('Unit | Validator | date', function () { value: 'not a date', context: options, }), - 'result: [CUSTOM] Test date must be a valid date' + 'result: [CUSTOM] Test date must be a valid date', ); assert.strictEqual( validator(key, 'not a date'), @@ -119,17 +119,17 @@ module('Unit | Validator | date', function () { value: 'not a date', context: options, }), - 'non-date string is not allowed' + 'non-date string is not allowed', ); assert.strictEqual( validator(key, NaN), buildMessage(key, { type: 'date', value: NaN, context: options }), - 'NaN is not allowed' + 'NaN is not allowed', ); assert.strictEqual( validator(key, {}), buildMessage(key, { type: 'date', value: {}, context: options }), - 'empty object is not allowed' + 'empty object is not allowed', ); }); @@ -150,7 +150,7 @@ module('Unit | Validator | date', function () { afterDate, message: `[BEFORE] date is NOT before ${afterDate}`, }), - 'date is after "before" date' + 'date is after "before" date', ); options = { before: () => startDate }; @@ -161,7 +161,7 @@ module('Unit | Validator | date', function () { afterDate, message: `[BEFORE] date is NOT before ${afterDate}`, }), - 'before accepts a function that returns a date' + 'before accepts a function that returns a date', ); options = { before: afterDate }; @@ -186,7 +186,7 @@ module('Unit | Validator | date', function () { afterDate, message: `[ON OR BEFORE] date is NOT on or before ${afterDate}`, }), - 'date is after "onOrBefore" date' + 'date is after "onOrBefore" date', ); options = { onOrBefore: () => startDate }; @@ -197,7 +197,7 @@ module('Unit | Validator | date', function () { afterDate, message: `[ON OR BEFORE] date is NOT on or before ${afterDate}`, }), - 'onOrBefore accepts a function that returns a date' + 'onOrBefore accepts a function that returns a date', ); options = { onOrBefore: afterDate }; @@ -222,7 +222,7 @@ module('Unit | Validator | date', function () { startDate, message: `[AFTER] date is NOT after ${startDate}`, }), - 'date is after the "after" date' + 'date is after the "after" date', ); options = { after: () => afterDate }; @@ -233,7 +233,7 @@ module('Unit | Validator | date', function () { startDate, message: `[AFTER] date is NOT after ${startDate}`, }), - 'after accepts a function that returns a date' + 'after accepts a function that returns a date', ); options = { after: startDate }; @@ -258,7 +258,7 @@ module('Unit | Validator | date', function () { onOrAfterDate, message: `[ON OR AFTER] date is NOT on or after ${startDate}`, }), - 'date onOrAfter the "onOrAfter" date is not allowed' + 'date onOrAfter the "onOrAfter" date is not allowed', ); options = { onOrAfter: () => onOrAfterDate }; @@ -269,7 +269,7 @@ module('Unit | Validator | date', function () { onOrAfterDate, message: `[ON OR AFTER] date is NOT on or after ${startDate}`, }), - 'onOrAfter accepts a function that returns a date' + 'onOrAfter accepts a function that returns a date', ); options = { onOrAfter: startDate }; @@ -294,7 +294,7 @@ module('Unit | Validator | date', function () { assert.strictEqual( validator(key, startDate), buildMessage(key, { message: 'custom message: before' }), - 'date on or after the "before" date is not allowed' + 'date on or after the "before" date is not allowed', ); }); @@ -314,7 +314,7 @@ module('Unit | Validator | date', function () { assert.strictEqual( validator(key, startDate), buildMessage(key, { message: 'custom message: onOrBefore' }), - 'date after the "onOrBefore" date is not allowed' + 'date after the "onOrBefore" date is not allowed', ); }); @@ -331,7 +331,7 @@ module('Unit | Validator | date', function () { assert.strictEqual( validator(key, startDate), buildMessage(key, { message: 'custom message: after' }), - 'date on or before the "after" date is not allowed' + 'date on or before the "after" date is not allowed', ); }); @@ -351,7 +351,7 @@ module('Unit | Validator | date', function () { assert.strictEqual( validator(key, startDate), buildMessage(key, { message: 'custom message: onOrAfter' }), - 'date before the "onOrAfter" date is not allowed' + 'date before the "onOrAfter" date is not allowed', ); }); }); diff --git a/tests/unit/validators/exclusion-test.js b/tests/unit/validators/exclusion-test.js index c7fbe29..d5fb115 100644 --- a/tests/unit/validators/exclusion-test.js +++ b/tests/unit/validators/exclusion-test.js @@ -16,7 +16,7 @@ module('Unit | Validator | exclusion', function () { type: 'exclusion', value: 'Manager', context: options, - }) + }), ); }); @@ -29,7 +29,7 @@ module('Unit | Validator | exclusion', function () { assert.true(validator(key, 61)); assert.strictEqual( validator(key, 21), - buildMessage(key, { type: 'exclusion', value: 21, context: options }) + buildMessage(key, { type: 'exclusion', value: 21, context: options }), ); }); @@ -44,7 +44,7 @@ module('Unit | Validator | exclusion', function () { assert.strictEqual( validator(key, 20), 'Your Age is invalid, should not be within 18,60', - 'custom message string generated correctly' + 'custom message string generated correctly', ); }); @@ -67,7 +67,7 @@ module('Unit | Validator | exclusion', function () { assert.strictEqual( validator(key, 'Test'), 'some test message', - 'custom message function is returned correctly' + 'custom message function is returned correctly', ); }); diff --git a/tests/unit/validators/format-test.js b/tests/unit/validators/format-test.js index 37ded8a..3e4742d 100644 --- a/tests/unit/validators/format-test.js +++ b/tests/unit/validators/format-test.js @@ -27,7 +27,7 @@ module('Unit | Validator | format', function () { assert.true(validator(key, 'http://lauren.com')); assert.strictEqual( validator(key, 'somevalue'), - buildMessage(key, { type: options.type }) + buildMessage(key, { type: options.type }), ); }); @@ -39,7 +39,7 @@ module('Unit | Validator | format', function () { assert.true(validator(key, 'secretword')); assert.strictEqual( validator(key, 'fail'), - buildMessage(key, { type: 'invalid' }) + buildMessage(key, { type: 'invalid' }), ); }); @@ -51,7 +51,7 @@ module('Unit | Validator | format', function () { assert.strictEqual( validator(key, 'test@example.com'), buildMessage(key, { type: 'email' }), - 'email fails format test' + 'email fails format test', ); assert.true(validator(key, 'notanemail'), 'non-email passes format test'); }); @@ -64,11 +64,11 @@ module('Unit | Validator | format', function () { assert.strictEqual( validator(key, 'customregex'), buildMessage(key, { type: 'invalid' }), - 'matching regex fails format test' + 'matching regex fails format test', ); assert.true( validator(key, 'notmatching'), - 'non-matching regex passes format test' + 'non-matching regex passes format test', ); }); @@ -83,7 +83,7 @@ module('Unit | Validator | format', function () { assert.strictEqual( validator(key, 'notaurl'), 'Url should be of type url', - 'custom message string is generated correctly' + 'custom message string is generated correctly', ); }); @@ -107,7 +107,7 @@ module('Unit | Validator | format', function () { assert.strictEqual( validator(key, 'notaurl'), 'some test message', - 'custom message function is returned correctly' + 'custom message function is returned correctly', ); }); }); diff --git a/tests/unit/validators/inclusion-test.js b/tests/unit/validators/inclusion-test.js index 1c8144a..2e32732 100644 --- a/tests/unit/validators/inclusion-test.js +++ b/tests/unit/validators/inclusion-test.js @@ -10,7 +10,7 @@ module('Unit | Validator | inclusion', function () { assert.strictEqual( validator(key, ''), - buildMessage(key, { type: 'inclusion', value: '', context: options }) + buildMessage(key, { type: 'inclusion', value: '', context: options }), ); assert.strictEqual( validator(key, 'Executive'), @@ -18,7 +18,7 @@ module('Unit | Validator | inclusion', function () { type: 'inclusion', value: 'Executive', context: options, - }) + }), ); assert.true(validator(key, 'Manager')); }); @@ -30,11 +30,11 @@ module('Unit | Validator | inclusion', function () { assert.strictEqual( validator(key, ''), - buildMessage(key, { type: 'inclusion', value: '', context: options }) + buildMessage(key, { type: 'inclusion', value: '', context: options }), ); assert.strictEqual( validator(key, 61), - buildMessage(key, { type: 'inclusion', value: 61, context: options }) + buildMessage(key, { type: 'inclusion', value: 61, context: options }), ); assert.true(validator(key, 21)); }); @@ -50,7 +50,7 @@ module('Unit | Validator | inclusion', function () { assert.strictEqual( validator(key, 92), 'Your Age is invalid, should be within 18,60', - 'custom message string is generated correctly' + 'custom message string is generated correctly', ); }); @@ -73,7 +73,7 @@ module('Unit | Validator | inclusion', function () { assert.strictEqual( validator(key, 'Test'), 'some test message', - 'custom message function is returned correctly' + 'custom message function is returned correctly', ); }); diff --git a/tests/unit/validators/length-test.js b/tests/unit/validators/length-test.js index 6bb2d92..535ade8 100644 --- a/tests/unit/validators/length-test.js +++ b/tests/unit/validators/length-test.js @@ -10,7 +10,7 @@ module('Unit | Validator | length', function () { assert.strictEqual( validator(key, ''), - buildMessage(key, { type: 'tooShort', value: '', context: options }) + buildMessage(key, { type: 'tooShort', value: '', context: options }), ); assert.true(validator(key, 'a')); }); @@ -24,7 +24,7 @@ module('Unit | Validator | length', function () { assert.true(validator(key, 'a')); assert.strictEqual( validator(key, 'ab'), - buildMessage(key, { type: 'tooLong', value: 'ab', context: options }) + buildMessage(key, { type: 'tooLong', value: 'ab', context: options }), ); }); @@ -35,14 +35,14 @@ module('Unit | Validator | length', function () { assert.strictEqual( validator(key, ''), - buildMessage(key, { type: 'between', value: '', context: options }) + buildMessage(key, { type: 'between', value: '', context: options }), ); assert.true(validator(key, 'a')); assert.true(validator(key, 'ab')); assert.true(validator(key, 'abc')); assert.strictEqual( validator(key, 'abcd'), - buildMessage(key, { type: 'between', value: '', context: options }) + buildMessage(key, { type: 'between', value: '', context: options }), ); }); @@ -53,12 +53,12 @@ module('Unit | Validator | length', function () { assert.strictEqual( validator(key, 'a'), - buildMessage(key, { type: 'wrongLength', value: '', context: options }) + buildMessage(key, { type: 'wrongLength', value: '', context: options }), ); assert.true(validator(key, 'ab')); assert.strictEqual( validator(key, 'abc'), - buildMessage(key, { type: 'wrongLength', value: '', context: options }) + buildMessage(key, { type: 'wrongLength', value: '', context: options }), ); }); @@ -81,7 +81,7 @@ module('Unit | Validator | length', function () { assert.strictEqual( validator(key, 'abc'), 'First name should be length 2', - 'custom messsage string is generated correctly' + 'custom messsage string is generated correctly', ); }); @@ -105,7 +105,7 @@ module('Unit | Validator | length', function () { assert.strictEqual( validator(key, 'abc'), 'some test message', - 'custom message function is returned correctly' + 'custom message function is returned correctly', ); }); }); diff --git a/tests/unit/validators/number-test.js b/tests/unit/validators/number-test.js index b7b2094..d6f2226 100644 --- a/tests/unit/validators/number-test.js +++ b/tests/unit/validators/number-test.js @@ -20,12 +20,12 @@ module('Unit | Validator | number', function () { value: 'not a number', context: options, }), - 'non-numeric string is not allowed' + 'non-numeric string is not allowed', ); assert.strictEqual( validator(key, NaN), buildMessage(key, { type: 'notANumber', value: NaN, context: options }), - 'NaN is not allowed' + 'NaN is not allowed', ); }); @@ -40,7 +40,7 @@ module('Unit | Validator | number', function () { type: 'notANumber', value: 'not a number', context: options, - }) + }), ); assert.true(validator(key, '7')); assert.true(validator(key, 7)); @@ -53,7 +53,7 @@ module('Unit | Validator | number', function () { assert.strictEqual( validator(key, ''), - buildMessage(key, { type: 'notANumber' }) + buildMessage(key, { type: 'notANumber' }), ); assert.true(validator(key, '7')); }); @@ -65,11 +65,11 @@ module('Unit | Validator | number', function () { assert.strictEqual( validator(key, null), - buildMessage(key, { type: 'notANumber' }) + buildMessage(key, { type: 'notANumber' }), ); assert.strictEqual( validator(key, undefined), - buildMessage(key, { type: 'notANumber' }) + buildMessage(key, { type: 'notANumber' }), ); }); @@ -84,7 +84,7 @@ module('Unit | Validator | number', function () { type: 'notAnInteger', value: '8.5', context: options, - }) + }), ); assert.true(validator(key, '7')); }); @@ -96,7 +96,7 @@ module('Unit | Validator | number', function () { assert.strictEqual( validator(key, '8.5'), - buildMessage(key, { type: 'equalTo', value: '8.5', context: options }) + buildMessage(key, { type: 'equalTo', value: '8.5', context: options }), ); assert.true(validator(key, '12')); }); @@ -108,11 +108,11 @@ module('Unit | Validator | number', function () { assert.strictEqual( validator(key, '15'), - buildMessage(key, { type: 'lessThan', value: '15', context: options }) + buildMessage(key, { type: 'lessThan', value: '15', context: options }), ); assert.strictEqual( validator(key, '12'), - buildMessage(key, { type: 'lessThan', value: '12', context: options }) + buildMessage(key, { type: 'lessThan', value: '12', context: options }), ); assert.true(validator(key, '4')); }); @@ -128,7 +128,7 @@ module('Unit | Validator | number', function () { type: 'lessThanOrEqualTo', value: '15', context: options, - }) + }), ); assert.true(validator(key, '12')); assert.true(validator(key, '4')); @@ -142,11 +142,11 @@ module('Unit | Validator | number', function () { assert.true(validator(key, '15')); assert.strictEqual( validator(key, '12'), - buildMessage(key, { type: 'greaterThan', value: '12', context: options }) + buildMessage(key, { type: 'greaterThan', value: '12', context: options }), ); assert.strictEqual( validator(key, '4'), - buildMessage(key, { type: 'greaterThan', value: '4', context: options }) + buildMessage(key, { type: 'greaterThan', value: '4', context: options }), ); }); @@ -163,7 +163,7 @@ module('Unit | Validator | number', function () { type: 'greaterThanOrEqualTo', value: '4', context: options, - }) + }), ); }); @@ -175,7 +175,7 @@ module('Unit | Validator | number', function () { assert.true(validator(key, '15')); assert.strictEqual( validator(key, '-12'), - buildMessage(key, { type: 'positive', value: '-12', context: options }) + buildMessage(key, { type: 'positive', value: '-12', context: options }), ); }); @@ -187,7 +187,7 @@ module('Unit | Validator | number', function () { assert.true(validator(key, '15')); assert.strictEqual( validator(key, '34'), - buildMessage(key, { type: 'odd', value: '34', context: options }) + buildMessage(key, { type: 'odd', value: '34', context: options }), ); }); @@ -198,7 +198,7 @@ module('Unit | Validator | number', function () { assert.strictEqual( validator(key, '15'), - buildMessage(key, { type: 'even', value: '15', context: options }) + buildMessage(key, { type: 'even', value: '15', context: options }), ); assert.true(validator(key, '34')); }); @@ -210,7 +210,7 @@ module('Unit | Validator | number', function () { assert.strictEqual( validator(key, '15'), - buildMessage(key, { type: 'multipleOf', value: '15', context: options }) + buildMessage(key, { type: 'multipleOf', value: '15', context: options }), ); assert.true(validator(key, '34')); }); @@ -223,7 +223,7 @@ module('Unit | Validator | number', function () { assert.strictEqual( validator(key, 33), 'Even Age is wrong', - 'custom message string is generated correctly' + 'custom message string is generated correctly', ); }); @@ -247,7 +247,7 @@ module('Unit | Validator | number', function () { assert.strictEqual( validator(key, 33), 'some test message', - 'custom message function is returned correctly' + 'custom message function is returned correctly', ); }); }); diff --git a/tests/unit/validators/presence-test.js b/tests/unit/validators/presence-test.js index 9f1d9a0..35cc799 100644 --- a/tests/unit/validators/presence-test.js +++ b/tests/unit/validators/presence-test.js @@ -9,15 +9,15 @@ module('Unit | Validator | presence', function () { assert.strictEqual( validator(key, undefined), - buildMessage(key, { type: 'present' }) + buildMessage(key, { type: 'present' }), ); assert.strictEqual( validator(key, null), - buildMessage(key, { type: 'present' }) + buildMessage(key, { type: 'present' }), ); assert.strictEqual( validator(key, ''), - buildMessage(key, { type: 'present' }) + buildMessage(key, { type: 'present' }), ); assert.true(validator(key, 'a')); }); @@ -31,7 +31,7 @@ module('Unit | Validator | presence', function () { assert.true(validator(key, '')); assert.strictEqual( validator(key, 'a'), - buildMessage(key, { type: 'blank' }) + buildMessage(key, { type: 'blank' }), ); }); @@ -41,15 +41,15 @@ module('Unit | Validator | presence', function () { assert.strictEqual( validator(key, undefined), - buildMessage(key, { type: 'present' }) + buildMessage(key, { type: 'present' }), ); assert.strictEqual( validator(key, null), - buildMessage(key, { type: 'present' }) + buildMessage(key, { type: 'present' }), ); assert.strictEqual( validator(key, ''), - buildMessage(key, { type: 'present' }) + buildMessage(key, { type: 'present' }), ); assert.true(validator(key, 'a')); }); @@ -63,7 +63,7 @@ module('Unit | Validator | presence', function () { assert.true(validator(key, '')); assert.strictEqual( validator(key, 'a'), - buildMessage(key, { type: 'blank' }) + buildMessage(key, { type: 'blank' }), ); }); @@ -94,21 +94,21 @@ module('Unit | Validator | presence', function () { assert.equal( validator(key, '', '', { [target]: 'a' }, {}), - expectedIfEmpty + expectedIfEmpty, ); assert.equal( validator(key, 'a', '', { [target]: 'a' }, {}), - expectedIfPresent + expectedIfPresent, ); // if the target is blank on the changes, it ignores the value in the content assert.equal( validator(key, '', '', { [target]: '' }, { [target]: 'a' }), - true + true, ); assert.equal( validator(key, 'a', '', { [target]: '' }, { [target]: 'a' }), - true + true, ); } @@ -168,7 +168,7 @@ module('Unit | Validator | presence', function () { assert.strictEqual( validator(key, ''), 'First name should be present', - 'custom message string is generated correctly' + 'custom message string is generated correctly', ); }); @@ -192,7 +192,7 @@ module('Unit | Validator | presence', function () { assert.strictEqual( validator(key, 'test'), 'some test message', - 'custom message function is returned correctly' + 'custom message function is returned correctly', ); }); });