Skip to content

Commit

Permalink
Require Node.js 12 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 17, 2021
1 parent c84b3ba commit 363c96f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 49 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ jobs:
node-version:
- 14
- 12
- 10
- 8
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
33 changes: 12 additions & 21 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
declare const isScoped: {
/**
Check if a string is a [scoped npm package name](https://docs.npmjs.com/misc/scope).
/**
Check if a string is a [scoped npm package name](https://docs.npmjs.com/misc/scope).
@example
```
import isScoped = require('is-scoped');
@example
```
import isScoped from 'is-scoped';
isScoped('@sindresorhus/df');
//=> true
isScoped('@sindresorhus/df');
//=> true
isScoped('cat-names');
//=> false
```
*/
(input: string): boolean;

// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function isScoped(input: string): boolean;
// export = isScoped;
default: typeof isScoped;
};

export = isScoped;
isScoped('cat-names');
//=> false
```
*/
export default function isScoped(string: string): boolean;
11 changes: 4 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
'use strict';
const scopedRegex = require('scoped-regex');
import scopedRegex from 'scoped-regex';

const isScoped = input => scopedRegex({exact: true}).test(input);

module.exports = isScoped;
// TODO: Remove this for the next major release
module.exports.default = isScoped;
export default function isScoped(string) {
return scopedRegex({exact: true}).test(string);
}
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expectType} from 'tsd';
import isScoped = require('.');
import isScoped from './index.js';

expectType<boolean>(isScoped('is-scoped'));
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
"description": "Check if a string is a scoped npm package name",
"license": "MIT",
"repository": "sindresorhus/is-scoped",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -30,11 +33,11 @@
"validation"
],
"dependencies": {
"scoped-regex": "^2.0.0"
"scoped-regex": "^3.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
}
}
10 changes: 1 addition & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

> Check if a string is a [scoped npm package name](https://docs.npmjs.com/misc/scope)

## Install

```
$ npm install is-scoped
```


## Usage

```js
const isScoped = require('is-scoped');
import isScoped from 'is-scoped';

isScoped('@sindresorhus/df');
//=> true
Expand All @@ -22,12 +20,6 @@ isScoped('cat-names');
//=> false
```


## Related

- [scoped-regex](https://github.com/sindresorhus/scoped-regex) - Regular expression for matching scoped npm package names


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import isScoped from '.';
import isScoped from './index.js';

const matches = [
'@sindresorhus/df',
Expand Down

0 comments on commit 363c96f

Please sign in to comment.