Skip to content
This repository was archived by the owner on Feb 4, 2018. It is now read-only.

Commit 94ebc5e

Browse files
authored
Merge pull request #98 from bem-sdk/issue-97
Deprecation
2 parents 184757d + f6d4675 commit 94ebc5e

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Contents
2828
* [API](#api)
2929
* [TypeScript support](#typescript-support)
3030
* [Debuggability](#debuggability)
31+
* [Deprecation](#deprecation)
3132

3233
Install
3334
-------
@@ -360,6 +361,19 @@ console.log(JSON.stringify(name));
360361
// ➜ {"block":"input","mod":{"name":"available","val":true}}
361362
```
362363

364+
Deprecation
365+
-----------
366+
367+
Deprecation is performed with [depd](https://github.com/dougwilson/nodejs-depd).
368+
369+
To silencing deprecation warnings from being output use the `NO_DEPRECATION` environment variable.
370+
371+
```
372+
NO_DEPRECATION=@bem/entity-name node app.js
373+
```
374+
375+
> More [details](https://github.com/dougwilson/nodejs-depd#processenvno_deprecation) in `depd` documentation
376+
363377
License
364378
-------
365379

index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const util = require('util');
44

55
const ExtendableError = require('es6-error');
66
const stringifyEntity = require('@bem/naming').stringify;
7+
const deprecate = require('depd')(require('./package.json').name);
78

89
/**
910
* Enum for types of BEM entities.
@@ -114,19 +115,27 @@ class BemEntityName {
114115
* If entity is not modifier then returns `undefined`.
115116
*
116117
* @returns {?string} - entity modifier name.
117-
* @deprecated - use `mod.name` instead.
118+
* @deprecated use {@link BemEntityName#mod.name}
118119
*/
119-
get modName() { return this.mod && this.mod.name; }
120+
get modName() {
121+
deprecate(`modName is kept just for compatibility and can be dropped in the future. Use mod.name instead in ${this.inspect()} at`);
122+
123+
return this.mod && this.mod.name;
124+
}
120125

121126
/**
122127
* Returns the modifier value of this entity.
123128
*
124129
* If entity is not modifier then returns `undefined`.
125130
*
126131
* @returns {?(string|true)} - entity modifier name.
127-
* @deprecated - use `mod.val` instead.
132+
* @deprecated use {@link BemEntityName#mod.val}
128133
*/
129-
get modVal() { return this.mod && this.mod.val; }
134+
get modVal() {
135+
deprecate(`modVal is kept just for compatibility and can be dropped in the future. Use mod.val instead in ${this.inspect()} at`);
136+
137+
return this.mod && this.mod.val;
138+
}
130139

131140
/**
132141
* Returns id for this entity.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@bem/naming": "2.0.0-5",
36+
"depd": "1.1.0",
3637
"es6-error": "4.0.2"
3738
},
3839
"devDependencies": {
@@ -51,7 +52,7 @@
5152
},
5253
"scripts": {
5354
"pretest": "npm run lint",
54-
"test": "nyc ava",
55+
"test": "NO_DEPRECATION=@bem/entity-name nyc ava",
5556
"lint": "npm run lint:js && npm run lint:dts",
5657
"lint:js": "eslint .",
5758
"lint:dts": "tslint **.d.ts",

0 commit comments

Comments
 (0)