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

Update build tooling and exports #1869

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6d27507
chore: bump babel and eslint
tux-tn Oct 16, 2021
2e24626
chore: update eslint config and fix no-else-return issues
tux-tn Oct 16, 2021
4658d17
chore: make tests and coverage reports more verbose
tux-tn Oct 16, 2021
d1fac02
docs: bump copyright year
tux-tn Oct 16, 2021
3739722
chore: bump actions versions in ci config
tux-tn Oct 16, 2021
b77b783
chore: replace npm install and npm test with cit short
tux-tn Oct 16, 2021
90b1287
chore: send coverage info for all node versions in matrix
tux-tn Oct 16, 2021
d92d167
chore: fallback to npm install and test (package-lock is not commited)
tux-tn Oct 16, 2021
d090307
chore: allow codecov to pick automatically the coverage file
tux-tn Oct 16, 2021
788591f
chore: add missing newline
tux-tn Oct 16, 2021
09db1f5
chore: remove unneeded linebreak from license
tux-tn Oct 30, 2021
1679f35
chore: reorder modules imports
tux-tn Oct 30, 2021
70d835c
chore: modernize package bundling and allow esm tree shaking
tux-tn Oct 30, 2021
d553ac6
chore: parse code in eslint as es8
tux-tn Oct 30, 2021
b5bcbac
test: hide removed command from test error message
tux-tn Oct 30, 2021
132576b
docs: add more details to usage description
tux-tn Oct 30, 2021
68232b0
chore: drop support of bower
tux-tn Oct 30, 2021
850f2d7
style(isIdentityCard): remove Unnecessary else
tux-tn Nov 15, 2021
24e038d
chore: bump dev dependencies
tux-tn Nov 15, 2021
58e7ca3
chore: bump version in es export
tux-tn Nov 15, 2021
668c7f5
chore: stop testing on EOL Node.js versions
tux-tn Oct 16, 2021
c2f3cfc
chore: remove unrelated test page
tux-tn Nov 16, 2021
2dbbaa0
Merge branch 'master' into chore/Tooling
tux-tn Apr 24, 2022
a22e76c
style: fix eslint max-len issue
Apr 24, 2022
5de0bd3
chore: bump dependencies
tux-tn Apr 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 3 additions & 22 deletions .babelrc
@@ -1,24 +1,5 @@
{
"env": {
"es": {
"presets": [
["@babel/preset-env", {
"modules": false
}]
]
},
"development": {
"presets": [
["@babel/preset-env", { "targets": { "node": "0.10" } }]
],
"plugins": [
[
"add-module-exports",
{
"addDefaultProperty": true
}
]
]
}
}
"presets": [
"@babel/preset-env"
]
}
57 changes: 34 additions & 23 deletions .eslintrc.json
@@ -1,40 +1,51 @@
{
"extends": "airbnb-base",
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
"sourceType": "module",
"allowImportExportEverywhere": false
},
"env": {
"es6": true,
"es2017": true,
"browser": true,
"node": true,
"mocha": true
},
"rules": {
"arrow-parens": 0,
"camelcase": 0,
"comma-dangle": [
2,
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}
],
"func-names": 0,
"implicit-arrow-linebreak": 0,
"linebreak-style": 0,
"newline-per-chained-call": 0,
"no-console": 0,
"no-misleading-character-class": 0,
"no-multiple-empty-lines": 0,
"no-param-reassign": 0,
"no-prototype-builtins": 0,
"no-plusplus": [
2,
{
"allowForLoopAfterthoughts": true
}
],
"no-restricted-globals": 0,
"no-restricted-syntax": [2, "DebuggerStatement", "LabeledStatement", "WithStatement"],
"no-useless-escape": 0,
"one-var": 0,
"one-var-declaration-per-line": 0,
"func-names": 0,
"no-console": 0,
"newline-per-chained-call": 0,
"operator-linebreak": 0,
"prefer-const": 0,
"linebreak-style": 0,
"no-restricted-syntax": [2, "DebuggerStatement", "LabeledStatement", "WithStatement"],
"no-restricted-globals": 0,
"prefer-destructuring": 0,
"comma-dangle": [2, {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}],
"no-plusplus": [2, {
"allowForLoopAfterthoughts": true
}],
"no-prototype-builtins": 0,
"no-useless-escape": 0
"prefer-destructuring": 0
}
}
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14, 12, 10, 8, 6]
node-version: [16, 14, 12]
name: Run tests on Node.js ${{ matrix.node-version }}
steps:
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2-beta
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
check-latest: true
Expand All @@ -23,8 +23,5 @@ jobs:
run: npm install
- name: Run tests
run: npm test
- if: matrix.node-version == 14
name: Send coverage info to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage/cobertura-coverage.xml
- name: Send coverage info to Codecov
uses: codecov/codecov-action@v2
6 changes: 3 additions & 3 deletions .github/workflows/npm-publish.yml
Expand Up @@ -6,10 +6,10 @@ jobs:
publish:
runs-on: ubuntu-20.04
steps:
- name: Setup Node.js 14
uses: actions/setup-node@v2-beta
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
check-latest: true
registry-url: https://registry.npmjs.org/
- name: Checkout Repository
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2018 Chris O'Hara <cohara87@gmail.com>
Copyright (c) 2021 Chris O'Hara <cohara87@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66 changes: 42 additions & 24 deletions README.md
Expand Up @@ -20,57 +20,76 @@ Passing anything other than a string will result in an error.

## Installation and Usage

### Server-side usage

Install the library with `npm install validator`

#### No ES6
### CommonJS (Node.js)

The library can be imported in node using the `require` syntax:

```javascript
var validator = require('validator');
const validator = require('validator');

validator.isEmail('foo@bar.com'); //=> true
```

#### ES6
### ECMAScript modules

The library can be used as an ECMAScript module with the `import` syntax:

```javascript
import validator from 'validator';
```

Or, import only a subset of the library:

```javascript
import isEmail from 'validator/lib/isEmail';
validator.isEmail('foo@bar.com'); //=> true
```

#### Tree-shakeable ES imports
You can also import only a subset of the library:


```javascript
import isEmail from 'validator/es/lib/isEmail';
```
import { isEmail, isURL } from 'validator';

### Client-side usage
isEmail('foo@bar.com'); //=> true
isURL('bar.com'); // => true
```

The library can be loaded either as a standalone script, or through an [AMD][amd]-compatible loader
### UMD (Browsers)
The library can be loaded either as a standalone script, or through an [AMD][amd]-compatible loader:

```html
<script type="text/javascript" src="validator.min.js"></script>
<script type="text/javascript">
validator.isEmail('foo@bar.com'); //=> true
</script>
```
### CDN

For CDN, you can use [unpkg][unpkg] or [jsDelivr][jsdelivr] and if you need a specific version you can just replace `latest` with the version number.

The library can also be installed through [bower][bower]
```html
<script src="https://unpkg.com/validator@latest"></script>
<script type="text/javascript">
validator.isEmail('foo@bar.com'); //=> true
</script>
```

```bash
$ bower install validator-js
```html
<script src="https://cdn.jsdelivr.net/npm/validator@latest"></script>
<script type="text/javascript">
validator.isEmail('foo@bar.com'); //=> true
</script>
```

CDN
#### JavaScript modules

If you target browsers that [support](https://caniuse.com/es6-module) JavaScript module scripts (aka ES6 modules), you can import the library as a module from `unpkg` or `jsDelivr`.
```html
<script src="https://unpkg.com/validator@latest/validator.min.js"></script>
<script type="module">
import { isEmail, isURL } from 'https://unpkg.com/validator?module'; // or https://cdn.jsdelivr.net/npm/validator/+esm if you want to use jsDelivr

isEmail('foo@bar.com'); //=> true
isURL('bar.com'); // => true
</script>

```

## Contributors
Expand Down Expand Up @@ -206,7 +225,6 @@ In general, we follow the "fork-and-pull" Git workflow.
3. Work on your fork
1. Make your changes and additions
- Most of your changes should be focused on `src/` and `test/` folders and/or `README.md`.
- Files such as `validator.js`, `validator.min.js` and files in `lib/` folder are autogenerated when running tests (`npm test`) and need not to be changed **manually**.
2. Change or add tests if needed
3. Run tests and make sure they pass
4. Add changes to README.md if needed
Expand Down Expand Up @@ -238,7 +256,7 @@ Remember, validating can be troublesome sometimes. See [A list of articles about
## License (MIT)

```
Copyright (c) 2018 Chris O'Hara <cohara87@gmail.com>
Copyright (c) 2021 Chris O'Hara <cohara87@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -278,7 +296,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[huntr-image]: https://cdn.huntr.dev/huntr_security_badge_mono.svg

[amd]: http://requirejs.org/docs/whyamd.html
[bower]: http://bower.io/

[unpkg]: http://unpkg.com/
[jsdelivr]: https://jsdelivr.com/
[mongoid]: http://docs.mongodb.org/manual/reference/object-id/
[ISIN]: https://en.wikipedia.org/wiki/International_Securities_Identification_Number
19 changes: 0 additions & 19 deletions bower.json

This file was deleted.

32 changes: 0 additions & 32 deletions build-browser.js

This file was deleted.