From 0ba20937885a08526f2908ba4d1b71b4d7ed3c46 Mon Sep 17 00:00:00 2001 From: blond Date: Sat, 15 Apr 2017 23:54:58 +0300 Subject: [PATCH 1/5] refactor(typings): add simple types --- globals.d.ts | 62 +++++++++++++++++----------------------------- index.d.ts | 20 +++++++-------- lib/entity-name.js | 22 ++++++++-------- 3 files changed, 44 insertions(+), 60 deletions(-) diff --git a/globals.d.ts b/globals.d.ts index c32f2a4..fe2a31d 100644 --- a/globals.d.ts +++ b/globals.d.ts @@ -3,107 +3,91 @@ declare namespace BemSDK { /** * Types of BEM entities. */ - export type TYPE = 'block' | 'blockMod' | 'elem' | 'elemMod'; + export type Type = 'block' | 'blockMod' | 'elem' | 'elemMod'; + export type BlockName = string; + export type ElementName = string; + export type ModifierName = string; + export type ModifierValue = string | true; + export type Id = string; /** * Abstract object to represent entity name */ - interface AbstractEntityRepresentation { + interface AbstractRepresentation { /** * The block name of entity. */ - block: string; + block: BlockName; /** * The element name of entity. */ - elem?: string; + elem?: ElementName; mod?: any; } /** * Object to represent modifier of entity name. */ - export interface ModifierRepresentation { + export interface Modifier { /** * The modifier name of entity. */ - name: string; + name: ModifierName; /** * The modifier value of entity. */ - val: string | true; + val: ModifierValue; } /** * Strict object to represent entity name. */ - export interface StrictRepresentation extends AbstractEntityRepresentation { + export interface Representation extends AbstractRepresentation { /** * The modifier of entity. */ - mod?: ModifierRepresentation; + mod?: Modifier; } /** * Object to create representation of entity name. */ - export interface Options extends AbstractEntityRepresentation { + export interface Options extends AbstractRepresentation { /** * The modifier of entity. */ - mod?: string | { + mod?: ModifierName | { /** * The modifier name of entity. */ - name: string; + name: ModifierName; /** * The modifier value of entity. */ - val?: string | boolean; + val?: ModifierValue; }; /** * The modifier name of entity. Used if `mod.name` wasn't specified. * @deprecated use `mod.name` instead. */ - modName?: string; + modName?: ModifierName; /** * The modifier value of entity. Used if neither `mod.val` nor `val` were not specified. * @deprecated use `mod.name` instead. */ - modVal?: string; + modVal?: ModifierValue; } /** - * Non-strict object to represent entity name. + * Object to create representation of entity name with `create` method. * * Contains old field: `val`, `modName` and `modVal. */ - export interface NonStrictRepresentation extends AbstractEntityRepresentation { - /** - * The modifier of entity. - */ - mod?: string | { - /** - * The modifier name of entity. - */ - name: string; - /** - * The modifier value of entity. - */ - val?: string | boolean; - }; + export interface CreateOptions extends Options { /** * The modifier value of entity. Used if neither `mod.val` were not specified. */ - val?: string; - /** - * The modifier name of entity. Used if `mod.name` wasn't specified. - */ - modName?: string; - /** - * The modifier value of entity. Used if neither `mod.val` nor `val` were not specified. - */ - modVal?: string; + val?: ModifierValue; } } } diff --git a/index.d.ts b/index.d.ts index 0467638..6cb2abc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,24 +3,24 @@ import './globals.d'; declare class BemEntityName { constructor(obj: BemSDK.EntityName.Options); - readonly block: string; - readonly elem: string | undefined; - readonly mod: BemSDK.EntityName.ModifierRepresentation | undefined; - readonly modName: string | undefined; - readonly modVal: string | true | undefined; - readonly type: BemSDK.EntityName.TYPE; + readonly block: BemSDK.EntityName.BlockName; + readonly elem: BemSDK.EntityName.ElementName | undefined; + readonly mod: BemSDK.EntityName.Modifier | undefined; + readonly modName: BemSDK.EntityName.ModifierName | undefined; + readonly modVal: BemSDK.EntityName.ModifierValue | undefined; + readonly type: BemSDK.EntityName.Type; readonly scope: BemEntityName | null; - readonly id: string; + readonly id: BemSDK.EntityName.Id; isSimpleMod(): boolean | null; isEqual(entityName: BemEntityName): boolean; belongsTo(entityName: BemEntityName): boolean; - valueOf(): BemSDK.EntityName.StrictRepresentation; - toJSON(): BemSDK.EntityName.StrictRepresentation; + valueOf(): BemSDK.EntityName.Representation; + toJSON(): BemSDK.EntityName.Representation; toString(): string; inspect(depth: number, options: object): string; - static create(obj: BemSDK.EntityName.NonStrictRepresentation | string): BemEntityName; + static create(obj: BemSDK.EntityName.CreateOptions | string): BemEntityName; static isBemEntityName(entityName: any): boolean; } diff --git a/lib/entity-name.js b/lib/entity-name.js index f638422..767ab2e 100644 --- a/lib/entity-name.js +++ b/lib/entity-name.js @@ -61,7 +61,7 @@ class BemEntityName { * * name.block; // button * - * @returns {string} name of entity block. + * @returns {BemSDK.EntityName.BlockName} name of entity block. */ get block() { return this._data.block; } @@ -76,7 +76,7 @@ class BemEntityName { * * name.elem; // text * - * @returns {?string} - name of entity element. + * @returns {?BemSDK.EntityName.ElementName} - name of entity element. */ get elem() { return this._data.elem; } @@ -94,7 +94,7 @@ class BemEntityName { * modName.mod; // { name: 'disabled', val: true } * blockName.mod; // undefined * - * @returns {?BemSDK.EntityName.ModifierRepresentation} - entity modifier. + * @returns {?BemSDK.EntityName.Modifier} - entity modifier. */ get mod() { return this._data.mod; } @@ -103,7 +103,7 @@ class BemEntityName { * * If entity is not modifier then returns `undefined`. * - * @returns {?string} - entity modifier name. + * @returns {?BemSDK.EntityName.ModifierName} - entity modifier name. * @deprecated use {@link BemEntityName#mod.name} */ get modName() { @@ -117,7 +117,7 @@ class BemEntityName { * * If entity is not modifier then returns `undefined`. * - * @returns {?(string|true)} - entity modifier name. + * @returns {?BemSDK.EntityName.ModifierValue} - entity modifier name. * @deprecated use {@link BemEntityName#mod.val} */ get modVal() { @@ -141,7 +141,7 @@ class BemEntityName { * * name.type; // elemMod * - * @returns {string} - type of entity. One of 'block', 'elem', 'blockMod', 'elemMod'. + * @returns {BemSDK.EntityName.Type} - type of entity. */ get type() { if (this._type) { return this._type; } @@ -172,7 +172,7 @@ class BemEntityName { * buttonTextName.scope; // BemEntityName { block: 'button' } * buttonTextBoldName.scope; // BemEntityName { block: 'button', elem: 'elem' } * - * @returns {BemEntityName} - scope entity name. + * @returns {(BemEntityName|null)} - scope entity name. */ get scope() { if (this.type === TYPES.BLOCK) { return null; } @@ -200,7 +200,7 @@ class BemEntityName { * * name.id; // button_disabled * - * @returns {string} - id of entity. + * @returns {BemSDK.EntityName.Id} - id of entity. */ get id() { if (this._id) { return this._id; } @@ -300,7 +300,7 @@ class BemEntityName { * * // ➜ { block: 'button', mod: { name: 'focused', value: true } } * - * @returns {BemSDK.EntityName.StrictRepresentation} + * @returns {BemSDK.EntityName.Representation} */ valueOf() { return this._data; } @@ -314,7 +314,7 @@ class BemEntityName { * * JSON.stringify(name); // {"block":"input","mod":{"name":"available","val":true}} * - * @returns {BemSDK.EntityName.StrictRepresentation} + * @returns {BemSDK.EntityName.Representation} */ toJSON() { return this._data; @@ -373,7 +373,7 @@ class BemEntityName { * BemEntityName.create({ block: 'my-button', modName: 'theme', modVal: 'red' }); * // → BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } } * - * @param {(BemSDK.EntityName.NonStrictRepresentation|string)} obj — representation of entity name. + * @param {(BemSDK.EntityName.CreateOptions|string)} obj — representation of entity name. * @returns {BemEntityName} An object representing entity name. */ static create(obj) { From 86e59d24bbcd59bb281827f1576d4f17e104fa01 Mon Sep 17 00:00:00 2001 From: blond Date: Mon, 17 Apr 2017 20:29:29 +0300 Subject: [PATCH 2/5] refactor(typings): rename global namespace to BEMSDK --- README.md | 2 +- globals.d.ts | 2 +- index.d.ts | 22 +++++++++++----------- lib/entity-name.js | 22 +++++++++++----------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 13b3cbb..dab8ee9 100644 --- a/README.md +++ b/README.md @@ -393,7 +393,7 @@ TypeScript support The package includes [typings](./index.d.ts) for TypeScript. You have to set up transpilation yourself. When you set `module` to `commonjs` in your `tsconfig.json` file, TypeScript will automatically find the type definitions for `@bem/entity-name`. -The interfaces are provided in global namespace `BemSDK.EntityName`. It is necessary to use interfaces in JsDoc. +The interfaces are provided in global namespace `BEMSDK.EntityName`. It is necessary to use interfaces in JsDoc. Debuggability ------------- diff --git a/globals.d.ts b/globals.d.ts index fe2a31d..2649364 100644 --- a/globals.d.ts +++ b/globals.d.ts @@ -1,4 +1,4 @@ -declare namespace BemSDK { +declare namespace BEMSDK { export namespace EntityName { /** * Types of BEM entities. diff --git a/index.d.ts b/index.d.ts index 6cb2abc..c77df24 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,26 +1,26 @@ import './globals.d'; declare class BemEntityName { - constructor(obj: BemSDK.EntityName.Options); + constructor(obj: BEMSDK.EntityName.Options); - readonly block: BemSDK.EntityName.BlockName; - readonly elem: BemSDK.EntityName.ElementName | undefined; - readonly mod: BemSDK.EntityName.Modifier | undefined; - readonly modName: BemSDK.EntityName.ModifierName | undefined; - readonly modVal: BemSDK.EntityName.ModifierValue | undefined; - readonly type: BemSDK.EntityName.Type; + readonly block: BEMSDK.EntityName.BlockName; + readonly elem: BEMSDK.EntityName.ElementName | undefined; + readonly mod: BEMSDK.EntityName.Modifier | undefined; + readonly modName: BEMSDK.EntityName.ModifierName | undefined; + readonly modVal: BEMSDK.EntityName.ModifierValue | undefined; + readonly type: BEMSDK.EntityName.Type; readonly scope: BemEntityName | null; - readonly id: BemSDK.EntityName.Id; + readonly id: BEMSDK.EntityName.Id; isSimpleMod(): boolean | null; isEqual(entityName: BemEntityName): boolean; belongsTo(entityName: BemEntityName): boolean; - valueOf(): BemSDK.EntityName.Representation; - toJSON(): BemSDK.EntityName.Representation; + valueOf(): BEMSDK.EntityName.Representation; + toJSON(): BEMSDK.EntityName.Representation; toString(): string; inspect(depth: number, options: object): string; - static create(obj: BemSDK.EntityName.CreateOptions | string): BemEntityName; + static create(obj: BEMSDK.EntityName.CreateOptions | string): BemEntityName; static isBemEntityName(entityName: any): boolean; } diff --git a/lib/entity-name.js b/lib/entity-name.js index 767ab2e..e9df938 100644 --- a/lib/entity-name.js +++ b/lib/entity-name.js @@ -22,7 +22,7 @@ const TYPES = { class BemEntityName { /** - * @param {BemSDK.EntityName.Options} obj — representation of entity name. + * @param {BEMSDK.EntityName.Options} obj — representation of entity name. */ constructor(obj) { if (!obj.block) { @@ -61,7 +61,7 @@ class BemEntityName { * * name.block; // button * - * @returns {BemSDK.EntityName.BlockName} name of entity block. + * @returns {BEMSDK.EntityName.BlockName} name of entity block. */ get block() { return this._data.block; } @@ -76,7 +76,7 @@ class BemEntityName { * * name.elem; // text * - * @returns {?BemSDK.EntityName.ElementName} - name of entity element. + * @returns {?BEMSDK.EntityName.ElementName} - name of entity element. */ get elem() { return this._data.elem; } @@ -94,7 +94,7 @@ class BemEntityName { * modName.mod; // { name: 'disabled', val: true } * blockName.mod; // undefined * - * @returns {?BemSDK.EntityName.Modifier} - entity modifier. + * @returns {?BEMSDK.EntityName.Modifier} - entity modifier. */ get mod() { return this._data.mod; } @@ -103,7 +103,7 @@ class BemEntityName { * * If entity is not modifier then returns `undefined`. * - * @returns {?BemSDK.EntityName.ModifierName} - entity modifier name. + * @returns {?BEMSDK.EntityName.ModifierName} - entity modifier name. * @deprecated use {@link BemEntityName#mod.name} */ get modName() { @@ -117,7 +117,7 @@ class BemEntityName { * * If entity is not modifier then returns `undefined`. * - * @returns {?BemSDK.EntityName.ModifierValue} - entity modifier name. + * @returns {?BEMSDK.EntityName.ModifierValue} - entity modifier name. * @deprecated use {@link BemEntityName#mod.val} */ get modVal() { @@ -141,7 +141,7 @@ class BemEntityName { * * name.type; // elemMod * - * @returns {BemSDK.EntityName.Type} - type of entity. + * @returns {BEMSDK.EntityName.Type} - type of entity. */ get type() { if (this._type) { return this._type; } @@ -200,7 +200,7 @@ class BemEntityName { * * name.id; // button_disabled * - * @returns {BemSDK.EntityName.Id} - id of entity. + * @returns {BEMSDK.EntityName.Id} - id of entity. */ get id() { if (this._id) { return this._id; } @@ -300,7 +300,7 @@ class BemEntityName { * * // ➜ { block: 'button', mod: { name: 'focused', value: true } } * - * @returns {BemSDK.EntityName.Representation} + * @returns {BEMSDK.EntityName.Representation} */ valueOf() { return this._data; } @@ -314,7 +314,7 @@ class BemEntityName { * * JSON.stringify(name); // {"block":"input","mod":{"name":"available","val":true}} * - * @returns {BemSDK.EntityName.Representation} + * @returns {BEMSDK.EntityName.Representation} */ toJSON() { return this._data; @@ -373,7 +373,7 @@ class BemEntityName { * BemEntityName.create({ block: 'my-button', modName: 'theme', modVal: 'red' }); * // → BemEntityName { block: 'my-button', mod: { name: 'theme', val: 'red' } } * - * @param {(BemSDK.EntityName.CreateOptions|string)} obj — representation of entity name. + * @param {(BEMSDK.EntityName.CreateOptions|string)} obj — representation of entity name. * @returns {BemEntityName} An object representing entity name. */ static create(obj) { From b87de5d682d22ca9062655978682d08b1d3661c9 Mon Sep 17 00:00:00 2001 From: blond Date: Mon, 17 Apr 2017 21:55:42 +0300 Subject: [PATCH 3/5] chore(typings): move types to `types` dir --- index.d.ts | 26 +------------------------- jsconfig.json | 23 +++++++++++++++-------- package.json | 6 +++--- types/entity-name.d.ts | 27 +++++++++++++++++++++++++++ globals.d.ts => types/globals.d.ts | 0 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 types/entity-name.d.ts rename globals.d.ts => types/globals.d.ts (100%) diff --git a/index.d.ts b/index.d.ts index c77df24..db6e1d0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,27 +1,3 @@ -import './globals.d'; - -declare class BemEntityName { - constructor(obj: BEMSDK.EntityName.Options); - - readonly block: BEMSDK.EntityName.BlockName; - readonly elem: BEMSDK.EntityName.ElementName | undefined; - readonly mod: BEMSDK.EntityName.Modifier | undefined; - readonly modName: BEMSDK.EntityName.ModifierName | undefined; - readonly modVal: BEMSDK.EntityName.ModifierValue | undefined; - readonly type: BEMSDK.EntityName.Type; - readonly scope: BemEntityName | null; - readonly id: BEMSDK.EntityName.Id; - - isSimpleMod(): boolean | null; - isEqual(entityName: BemEntityName): boolean; - belongsTo(entityName: BemEntityName): boolean; - valueOf(): BEMSDK.EntityName.Representation; - toJSON(): BEMSDK.EntityName.Representation; - toString(): string; - inspect(depth: number, options: object): string; - - static create(obj: BEMSDK.EntityName.CreateOptions | string): BemEntityName; - static isBemEntityName(entityName: any): boolean; -} +import BemEntityName from './types/entity-name.d'; export = BemEntityName; diff --git a/jsconfig.json b/jsconfig.json index 057fd64..cb9be6b 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,10 +1,17 @@ { - "compilerOptions": { - "target": "ES6", - "module": "commonjs" - }, - "files": [ - "index.js", - "index.d.ts" - ] + "compilerOptions": { + "target": "ES6", + "module": "commonjs" + }, + "include": [ + "lib", + "types" + ], + "exclude": [ + "node_modules" + ], + "files": [ + "index.js", + "index.d.ts" + ] } diff --git a/package.json b/package.json index 2de9445..824a29a 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,9 @@ "typings": "index.d.ts", "files": [ "lib/**", + "types/**", "index.js", - "index.d.ts", - "globals.d.ts" + "index.d.ts" ], "engines": { "node": ">= 4.0" @@ -56,7 +56,7 @@ "test": "nyc ava", "lint": "npm run lint:js && npm run lint:dts", "lint:js": "eslint .", - "lint:dts": "tslint **.d.ts", + "lint:dts": "tslint types/*.d.ts", "coveralls": "nyc report --reporter=text-lcov | coveralls" }, "ava": { diff --git a/types/entity-name.d.ts b/types/entity-name.d.ts new file mode 100644 index 0000000..c77df24 --- /dev/null +++ b/types/entity-name.d.ts @@ -0,0 +1,27 @@ +import './globals.d'; + +declare class BemEntityName { + constructor(obj: BEMSDK.EntityName.Options); + + readonly block: BEMSDK.EntityName.BlockName; + readonly elem: BEMSDK.EntityName.ElementName | undefined; + readonly mod: BEMSDK.EntityName.Modifier | undefined; + readonly modName: BEMSDK.EntityName.ModifierName | undefined; + readonly modVal: BEMSDK.EntityName.ModifierValue | undefined; + readonly type: BEMSDK.EntityName.Type; + readonly scope: BemEntityName | null; + readonly id: BEMSDK.EntityName.Id; + + isSimpleMod(): boolean | null; + isEqual(entityName: BemEntityName): boolean; + belongsTo(entityName: BemEntityName): boolean; + valueOf(): BEMSDK.EntityName.Representation; + toJSON(): BEMSDK.EntityName.Representation; + toString(): string; + inspect(depth: number, options: object): string; + + static create(obj: BEMSDK.EntityName.CreateOptions | string): BemEntityName; + static isBemEntityName(entityName: any): boolean; +} + +export = BemEntityName; diff --git a/globals.d.ts b/types/globals.d.ts similarity index 100% rename from globals.d.ts rename to types/globals.d.ts From a1bc9bd11660ce68fcce9b18c69074c74bb63ee5 Mon Sep 17 00:00:00 2001 From: blond Date: Sat, 15 Apr 2017 23:55:27 +0300 Subject: [PATCH 4/5] test(typing): use imports for typing It is necessary for types, that provides module with `export default`. --- test/belongs-to.test.js | 4 ++-- test/bem-fields.test.js | 2 +- test/create.test.js | 2 +- test/deprecate.test.js | 8 ++++---- test/entity-type-error.test.js | 4 ++-- test/id.test.js | 6 +++--- test/inspect.test.js | 8 ++++---- test/is-bem-entity-name.test.js | 2 +- test/is-equal.test.js | 2 +- test/is-simple-mod.test.js | 2 +- test/scope.test.js | 2 +- test/to-json.test.js | 2 +- test/to-string.test.js | 4 ++-- test/type.test.js | 2 +- test/value-of.test.js | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/test/belongs-to.test.js b/test/belongs-to.test.js index fc17a2e..fe80f0e 100644 --- a/test/belongs-to.test.js +++ b/test/belongs-to.test.js @@ -1,6 +1,6 @@ -const test = require('ava'); +import test from 'ava'; -const BemEntityName = require('../lib/entity-name'); +import BemEntityName from '..'; test('should not detect belonging between block and itself', t => { const blockName = new BemEntityName({ block: 'block' }); diff --git a/test/bem-fields.test.js b/test/bem-fields.test.js index 792b227..e1ab0dd 100644 --- a/test/bem-fields.test.js +++ b/test/bem-fields.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should provide `block` field', t => { const entityName = new BemEntityName({ block: 'block' }); diff --git a/test/create.test.js b/test/create.test.js index 62c00ab..021e83d 100644 --- a/test/create.test.js +++ b/test/create.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should return object as is if it`s a BemEntityName', t => { const entityName = new BemEntityName({ block: 'block' }); diff --git a/test/deprecate.test.js b/test/deprecate.test.js index d5cf1c2..144be4d 100644 --- a/test/deprecate.test.js +++ b/test/deprecate.test.js @@ -1,8 +1,8 @@ -const test = require('ava'); -const sinon = require('sinon'); -const proxyquire = require('proxyquire'); +import test from 'ava'; +import sinon from 'sinon'; +import proxyquire from 'proxyquire'; -const BemEntityName = require('../lib/entity-name'); +import BemEntityName from '..'; const deprecateSpy = sinon.spy(); const deprecate = proxyquire('../lib/deprecate', { diff --git a/test/entity-type-error.test.js b/test/entity-type-error.test.js index fdb35a0..824edc7 100644 --- a/test/entity-type-error.test.js +++ b/test/entity-type-error.test.js @@ -1,6 +1,6 @@ -const test = require('ava'); +import test from 'ava'; -const EntityTypeError = require('../lib/entity-type-error'); +import EntityTypeError from '../lib/entity-type-error'; test('should create type error', t => { const error = new EntityTypeError(); diff --git a/test/id.test.js b/test/id.test.js index 9fc82b9..fa43eb3 100644 --- a/test/id.test.js +++ b/test/id.test.js @@ -1,8 +1,8 @@ import test from 'ava'; -const sinon = require('sinon'); -const proxyquire = require('proxyquire'); +import sinon from 'sinon'; +import proxyquire from 'proxyquire'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should build equal id for equal blocks', t => { const entityName1 = new BemEntityName({ block: 'block' }); diff --git a/test/inspect.test.js b/test/inspect.test.js index 14807ba..51b5813 100644 --- a/test/inspect.test.js +++ b/test/inspect.test.js @@ -1,9 +1,9 @@ -import test from 'ava'; -const sinon = require('sinon'); +import {EOL} from 'os'; -import BemEntityName from '../lib/entity-name'; +import test from 'ava'; +import sinon from 'sinon'; -const EOL = require('os').EOL; +import BemEntityName from '..'; test.beforeEach(t => { t.context.stdoutWriteStub = sinon.stub(process.stdout, 'write'); diff --git a/test/is-bem-entity-name.test.js b/test/is-bem-entity-name.test.js index 8dcdb85..e7f0b08 100644 --- a/test/is-bem-entity-name.test.js +++ b/test/is-bem-entity-name.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should check valid entities', t => { const entityName = new BemEntityName({ block: 'block' }); diff --git a/test/is-equal.test.js b/test/is-equal.test.js index cb9e39b..52eac2f 100644 --- a/test/is-equal.test.js +++ b/test/is-equal.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should detect equal block', t => { const entityName1 = new BemEntityName({ block: 'block' }); diff --git a/test/is-simple-mod.test.js b/test/is-simple-mod.test.js index 6426209..34d46fa 100644 --- a/test/is-simple-mod.test.js +++ b/test/is-simple-mod.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should be true for simple modifiers', t => { const entityName = new BemEntityName({ block: 'block', mod: 'mod' }); diff --git a/test/scope.test.js b/test/scope.test.js index 32318cf..15549ef 100644 --- a/test/scope.test.js +++ b/test/scope.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should return scope of block', t => { const entityName = new BemEntityName({ block: 'block' }); diff --git a/test/to-json.test.js b/test/to-json.test.js index 7b5ce5e..a062cca 100644 --- a/test/to-json.test.js +++ b/test/to-json.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should create stringified object', t => { const entityName = new BemEntityName({ block: 'button' }); diff --git a/test/to-string.test.js b/test/to-string.test.js index e5ebd77..1d15be7 100644 --- a/test/to-string.test.js +++ b/test/to-string.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -const sinon = require('sinon'); -const proxyquire = require('proxyquire'); +import sinon from 'sinon'; +import proxyquire from 'proxyquire'; const spy = sinon.spy(); const BemEntityName = proxyquire('../lib/entity-name', { diff --git a/test/type.test.js b/test/type.test.js index a3bd312..67059e9 100644 --- a/test/type.test.js +++ b/test/type.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should determine block', t => { const entityName = new BemEntityName({ block: 'block' }); diff --git a/test/value-of.test.js b/test/value-of.test.js index 6efb5b2..085073c 100644 --- a/test/value-of.test.js +++ b/test/value-of.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import BemEntityName from '../lib/entity-name'; +import BemEntityName from '..'; test('should return normalized object', t => { const entity = new BemEntityName({ block: 'block', mod: 'mod' }); From cedd0ea4a14bb2db72dc2e8e84703d2996119a9f Mon Sep 17 00:00:00 2001 From: blond Date: Mon, 17 Apr 2017 22:00:29 +0300 Subject: [PATCH 5/5] chore(package): add node types --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 824a29a..d9b8e7e 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "es6-error": "4.0.2" }, "devDependencies": { + "@types/node": "^4.2.5", "@types/proxyquire": "^1.3.27", "@types/sinon": "^2.1.2", "ava": "^0.19.0",