Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to ES6 #496

Merged
merged 41 commits into from
Feb 21, 2016
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
61906f0
Replace jshint with eslint
forabi Feb 11, 2016
d369a39
Migrate to ES6
forabi Feb 11, 2016
5dc5c24
Remove tests from bower ignore (does not exist)
forabi Feb 11, 2016
0ebb3b4
ESLint: ignore builds and tests
forabi Feb 11, 2016
2487421
Restore test for AMD
forabi Feb 11, 2016
95f853b
Restore deprecation message but do not coerce
forabi Feb 12, 2016
9b73512
ESLint: move ignore to .eslintignore
forabi Feb 12, 2016
150667d
ESLint: extends not needed in test dir
forabi Feb 12, 2016
51aaaa9
Tidy up npm scripts
forabi Feb 12, 2016
d5d53fe
Update builds
forabi Feb 12, 2016
daa442a
Readd comments to browser builds, do not join variables in unminified…
forabi Feb 13, 2016
8aa4a57
Revert version number
forabi Feb 13, 2016
238248a
Add for-in guard
forabi Feb 13, 2016
850286d
Revert depd version
forabi Feb 13, 2016
7832ee3
Remove unnecessary prototype check in toDate
forabi Feb 13, 2016
1a264a0
Revert version number in source
forabi Feb 13, 2016
ad5c980
Remove coersion test
forabi Feb 13, 2016
c9efde6
Remove depd and all related deprecation code
forabi Feb 13, 2016
760015d
Fix isBefore and isAfter defaulting to Date instance instead of string
forabi Feb 13, 2016
3cdb173
Move util to lib/util (only in builds)
forabi Feb 13, 2016
2a3a92d
disable no console warning in root dir
forabi Feb 13, 2016
81337be
Remove unnecessary ignore rules
forabi Feb 13, 2016
0283443
Remove Makefile from bower.json
forabi Feb 13, 2016
bd5e68b
Add explicit dependency "babel-core"
forabi Feb 13, 2016
5197625
ESLint: Add no console warning in src
forabi Feb 13, 2016
11c98c8
Build script: move resolveModuleSource outside waterfall function
forabi Feb 13, 2016
e53389a
bower: ignore index, build and package.json
forabi Feb 13, 2016
bf9232a
Keep things simple
forabi Feb 14, 2016
eaf5088
Specify package files instead of ignored files
forabi Feb 14, 2016
e25b884
assertString throw a TypeError
forabi Feb 15, 2016
a2c4471
Remove extend documentation from README
forabi Feb 15, 2016
8b84882
Add isMobilePhone validation for ar-SY, isAlpha and isAlphanumeric fo…
forabi Feb 16, 2016
369b753
Lint tests
forabi Feb 16, 2016
95f355c
Add Arabic locales with tests for isAlpha and isAlphanumeric
forabi Feb 16, 2016
e44ca88
Update README: Add new Arabic locales
forabi Feb 16, 2016
f919358
Prefer template strings
forabi Feb 20, 2016
af94fb7
Upgrade to ESLint 2, remove unnecessary deps
forabi Feb 21, 2016
b1ff8bc
Remove old ESLint config file
forabi Feb 21, 2016
bf16624
Fix ESLint config
forabi Feb 21, 2016
be9fb9c
Rebase on 4.9.0
forabi Feb 21, 2016
a33b64b
Fix README.md
forabi Feb 21, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
validator.js
validator.min.js
test
19 changes: 19 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "airbnb/base",
"parserOptions": {
"sourceType": "module"
},
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true
},
"rules": {
"camelcase": [0],
"prefer-template": 0,
"no-param-reassign": [0],
"one-var": 0,
"func-names": 0
}
}
3 changes: 0 additions & 3 deletions .jshintrc

This file was deleted.

2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.eslintrc
build-browser.js
34 changes: 0 additions & 34 deletions Makefile

This file was deleted.

8 changes: 5 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
"license": "MIT",
"ignore": [
"**/.*",
"index.js",
"build*.js",
"package.json",
".babelrc",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already handled by the **/.* rule.

"node_modules",
"bower_components",
"test",
"tests",
"Makefile",
"package.json"
"Makefile"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Makefile no longer exists.

]
}
23 changes: 23 additions & 0 deletions build-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const pkg = require('./package.json');
const rollup = require('rollup').rollup;
const babel = require('rollup-plugin-babel');

rollup({
entry: 'src/index.js',
plugins: [
babel({
presets: ['es2015-rollup'],
plugins: ['transform-node-env-inline'],
babelrc: false,
}),
],
}).then(bundle => (
bundle.write({
dest: 'validator.js',
format: 'umd',
moduleName: pkg.name,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still work with all of the import schemes defined here? e.g. #448

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chriso I do not use Ember so I'm not sure. Maybe some one can help test it? If it does not work I can open a rollup issue to fix it there.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is what is causing issues when I tried to switch to es6 modules in an ember app - TryGhost/Admin#34

Please let me know if there is any way I can help resolve the issue.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinansfield the rollup package is responsible for generating the output code. There may be a rollup plugin that works for Ember, or a patch to the main rollup repo might be required. I'm happy to quickly accept a PR that fixes the problem or updates dependencies. I don't use Ember so cannot test fixes.

})
)).catch(e => {
process.stderr.write(e.message + '\n');
process.exit(1);
});
273 changes: 273 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _toDate = require('./lib/toDate');

var _toDate2 = _interopRequireDefault(_toDate);

var _toFloat = require('./lib/toFloat');

var _toFloat2 = _interopRequireDefault(_toFloat);

var _toInt = require('./lib/toInt');

var _toInt2 = _interopRequireDefault(_toInt);

var _toBoolean = require('./lib/toBoolean');

var _toBoolean2 = _interopRequireDefault(_toBoolean);

var _equals = require('./lib/equals');

var _equals2 = _interopRequireDefault(_equals);

var _contains = require('./lib/contains');

var _contains2 = _interopRequireDefault(_contains);

var _matches = require('./lib/matches');

var _matches2 = _interopRequireDefault(_matches);

var _isEmail = require('./lib/isEmail');

var _isEmail2 = _interopRequireDefault(_isEmail);

var _isURL = require('./lib/isURL');

var _isURL2 = _interopRequireDefault(_isURL);

var _isMACAddress = require('./lib/isMACAddress');

var _isMACAddress2 = _interopRequireDefault(_isMACAddress);

var _isIP = require('./lib/isIP');

var _isIP2 = _interopRequireDefault(_isIP);

var _isFQDN = require('./lib/isFQDN');

var _isFQDN2 = _interopRequireDefault(_isFQDN);

var _isBoolean = require('./lib/isBoolean');

var _isBoolean2 = _interopRequireDefault(_isBoolean);

var _isAlpha = require('./lib/isAlpha');

var _isAlpha2 = _interopRequireDefault(_isAlpha);

var _isAlphanumeric = require('./lib/isAlphanumeric');

var _isAlphanumeric2 = _interopRequireDefault(_isAlphanumeric);

var _isNumeric = require('./lib/isNumeric');

var _isNumeric2 = _interopRequireDefault(_isNumeric);

var _isLowercase = require('./lib/isLowercase');

var _isLowercase2 = _interopRequireDefault(_isLowercase);

var _isUppercase = require('./lib/isUppercase');

var _isUppercase2 = _interopRequireDefault(_isUppercase);

var _isAscii = require('./lib/isAscii');

var _isAscii2 = _interopRequireDefault(_isAscii);

var _isFullWidth = require('./lib/isFullWidth');

var _isFullWidth2 = _interopRequireDefault(_isFullWidth);

var _isHalfWidth = require('./lib/isHalfWidth');

var _isHalfWidth2 = _interopRequireDefault(_isHalfWidth);

var _isVariableWidth = require('./lib/isVariableWidth');

var _isVariableWidth2 = _interopRequireDefault(_isVariableWidth);

var _isMultibyte = require('./lib/isMultibyte');

var _isMultibyte2 = _interopRequireDefault(_isMultibyte);

var _isSurrogatePair = require('./lib/isSurrogatePair');

var _isSurrogatePair2 = _interopRequireDefault(_isSurrogatePair);

var _isInt = require('./lib/isInt');

var _isInt2 = _interopRequireDefault(_isInt);

var _isFloat = require('./lib/isFloat');

var _isFloat2 = _interopRequireDefault(_isFloat);

var _isDecimal = require('./lib/isDecimal');

var _isDecimal2 = _interopRequireDefault(_isDecimal);

var _isHexadecimal = require('./lib/isHexadecimal');

var _isHexadecimal2 = _interopRequireDefault(_isHexadecimal);

var _isDivisibleBy = require('./lib/isDivisibleBy');

var _isDivisibleBy2 = _interopRequireDefault(_isDivisibleBy);

var _isHexColor = require('./lib/isHexColor');

var _isHexColor2 = _interopRequireDefault(_isHexColor);

var _isJSON = require('./lib/isJSON');

var _isJSON2 = _interopRequireDefault(_isJSON);

var _isNull = require('./lib/isNull');

var _isNull2 = _interopRequireDefault(_isNull);

var _isLength = require('./lib/isLength');

var _isLength2 = _interopRequireDefault(_isLength);

var _isByteLength = require('./lib/isByteLength');

var _isByteLength2 = _interopRequireDefault(_isByteLength);

var _isUUID = require('./lib/isUUID');

var _isUUID2 = _interopRequireDefault(_isUUID);

var _isMongoId = require('./lib/isMongoId');

var _isMongoId2 = _interopRequireDefault(_isMongoId);

var _isDate = require('./lib/isDate');

var _isDate2 = _interopRequireDefault(_isDate);

var _isAfter = require('./lib/isAfter');

var _isAfter2 = _interopRequireDefault(_isAfter);

var _isBefore = require('./lib/isBefore');

var _isBefore2 = _interopRequireDefault(_isBefore);

var _isIn = require('./lib/isIn');

var _isIn2 = _interopRequireDefault(_isIn);

var _isCreditCard = require('./lib/isCreditCard');

var _isCreditCard2 = _interopRequireDefault(_isCreditCard);

var _isISIN = require('./lib/isISIN');

var _isISIN2 = _interopRequireDefault(_isISIN);

var _isISBN = require('./lib/isISBN');

var _isISBN2 = _interopRequireDefault(_isISBN);

var _isMobilePhone = require('./lib/isMobilePhone');

var _isMobilePhone2 = _interopRequireDefault(_isMobilePhone);

var _isCurrency = require('./lib/isCurrency');

var _isCurrency2 = _interopRequireDefault(_isCurrency);

var _isISO = require('./lib/isISO8601');

var _isISO2 = _interopRequireDefault(_isISO);

var _isBase = require('./lib/isBase64');

var _isBase2 = _interopRequireDefault(_isBase);

var _ltrim = require('./lib/ltrim');

var _ltrim2 = _interopRequireDefault(_ltrim);

var _rtrim = require('./lib/rtrim');

var _rtrim2 = _interopRequireDefault(_rtrim);

var _trim = require('./lib/trim');

var _trim2 = _interopRequireDefault(_trim);

var _escape = require('./lib/escape');

var _escape2 = _interopRequireDefault(_escape);

var _stripLow = require('./lib/stripLow');

var _stripLow2 = _interopRequireDefault(_stripLow);

var _whitelist = require('./lib/whitelist');

var _whitelist2 = _interopRequireDefault(_whitelist);

var _blacklist = require('./lib/blacklist');

var _blacklist2 = _interopRequireDefault(_blacklist);

var _isWhitelisted = require('./lib/isWhitelisted');

var _isWhitelisted2 = _interopRequireDefault(_isWhitelisted);

var _normalizeEmail = require('./lib/normalizeEmail');

var _normalizeEmail2 = _interopRequireDefault(_normalizeEmail);

var _toString = require('./util/toString');

var _toString2 = _interopRequireDefault(_toString);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var version = '5.0.0';

var validator = {
version: version,
toDate: _toDate2.default,
toFloat: _toFloat2.default, toInt: _toInt2.default,
toBoolean: _toBoolean2.default,
equals: _equals2.default, contains: _contains2.default, matches: _matches2.default,
isEmail: _isEmail2.default, isURL: _isURL2.default, isMACAddress: _isMACAddress2.default, isIP: _isIP2.default, isFQDN: _isFQDN2.default,
isBoolean: _isBoolean2.default,
isAlpha: _isAlpha2.default, isAlphanumeric: _isAlphanumeric2.default, isNumeric: _isNumeric2.default, isLowercase: _isLowercase2.default, isUppercase: _isUppercase2.default,
isAscii: _isAscii2.default, isFullWidth: _isFullWidth2.default, isHalfWidth: _isHalfWidth2.default, isVariableWidth: _isVariableWidth2.default,
isMultibyte: _isMultibyte2.default, isSurrogatePair: _isSurrogatePair2.default,
isInt: _isInt2.default, isFloat: _isFloat2.default, isDecimal: _isDecimal2.default, isHexadecimal: _isHexadecimal2.default, isDivisibleBy: _isDivisibleBy2.default,
isHexColor: _isHexColor2.default,
isJSON: _isJSON2.default,
isNull: _isNull2.default,
isLength: _isLength2.default, isByteLength: _isByteLength2.default,
isUUID: _isUUID2.default, isMongoId: _isMongoId2.default,
isDate: _isDate2.default, isAfter: _isAfter2.default, isBefore: _isBefore2.default,
isIn: _isIn2.default,
isCreditCard: _isCreditCard2.default,
isISIN: _isISIN2.default, isISBN: _isISBN2.default,
isMobilePhone: _isMobilePhone2.default,
isCurrency: _isCurrency2.default,
isISO8601: _isISO2.default,
isBase64: _isBase2.default,
ltrim: _ltrim2.default, rtrim: _rtrim2.default, trim: _trim2.default,
escape: _escape2.default, stripLow: _stripLow2.default,
whitelist: _whitelist2.default, blacklist: _blacklist2.default,
isWhitelisted: _isWhitelisted2.default,
normalizeEmail: _normalizeEmail2.default,
toString: _toString2.default
};

exports.default = validator;
module.exports = exports['default'];
6 changes: 6 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"module": "system",
"target": "ES6"
}
}
Loading