Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
chore(lynt): fix glob patterns in lint and format
Browse files Browse the repository at this point in the history
Without escaping them the originating shell expands the glob patterns which can be inconsistent.
  • Loading branch information
eps1lon committed Jun 15, 2018
1 parent b568c1a commit 4ab5548
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
// Set the default
"editor.formatOnSave": false,
"typescript.tsdk": "node_modules\\typescript\\lib",
"typescript.tsdk": "node_modules/typescript/lib",
"[typescript]": {
"editor.formatOnSave": true
},
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
"build:check": "tsc --project ./tsconfig.build.json --noEmit --watch",
"clean": "rimraf coverage dist",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"format": "prettier --write src/**/*.ts",
"format:check": "prettier --list-different src/**/*.ts",
"generate-locale-data:clean": "rimraf locale-data/**/*.json",
"format": "prettier --write \"src/**/*.ts\"",
"format:check": "prettier --list-different \"src/**/*.ts\"",
"generate-locale-data:clean": "rimraf \"locale-data/**/*.json\"",
"generate-locale-data": "yarn run parse-locale-data && yarn run process-locale-data",
"generate-skill-meta": "node scripts/generateSkillMeta",
"postgenerate-skill-meta": "prettier --write src/translate/skill_meta.json",
"parse-locale-data": "node scripts/generateLocaleData",
"process-locale-data": "node scripts/sieveUnprocessed",
"postprocess-locale-data": "prettier --write locale-data/**/*stat_descriptions.json",
"postprocess-locale-data": "prettier --write \"locale-data/**/*stat_descriptions.json\"",
"generate-dat-locale-data": "node scripts/generateDatLocaleData",
"postgenerate-dat-locale-data": "prettier --write locale-data/**/[A-Z]*.json",
"lint": "tslint --project tsconfig.json src/**/*.ts",
"postgenerate-dat-locale-data": "prettier --write \"locale-data/**/[A-Z]*.json\"",
"lint": "tslint --project tsconfig.json \"src/**/*.ts\"",
"compile-grammars": "node scripts/compileGrammars",
"compile-grammars:watch": "node scripts/watchGrammars",
"prepublishOnly": "yarn run build",
Expand Down
6 changes: 3 additions & 3 deletions src/format/__tests__/formatStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ it('should translate collections of stats', () => {

// they are save in the .txt with `no_description id`
it('should return the id with a hint for no_desc stats', () => {
expect(
formatStats([{ id: 'item_drop_slots', value: 3 }], { datas })
).toEqual(['item_drop_slots (hidden)']);
expect(formatStats([{ id: 'item_drop_slots', value: 3 }], { datas })).toEqual(
['item_drop_slots (hidden)']
);
});

it('should translate production bug 1', () => {
Expand Down
14 changes: 7 additions & 7 deletions src/localize/formatters/Formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
*/
export default interface Formatter {
/**
*
* @param n
* RegExp to match the value in the formatted string
*/
regexp: string;
/**
*
* @param n
*/
format(n: number): string;
/**
* inverse of #format
* @param s returnval from #format()
*/
inverse(s: string): number;
/**
* RegExp to match the value in the formatted string
*/
regexp: string;
}
}
6 changes: 1 addition & 5 deletions src/localize/formatters/__tests__/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import factory, {
formatters,
inverseFactory,
regexpFactory
} from '../';
import factory, { formatters, inverseFactory, regexpFactory } from '../';

it('should throw if the specified formatter doesnt exist', () => {
expect(() => factory('foobar')).toThrowError("'foobar' not found");
Expand Down
6 changes: 3 additions & 3 deletions src/localize/formatters/__tests__/regexp_util.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {NUMBER} from '../regexp_util';
import { NUMBER } from '../regexp_util';

it('can match hole numbers', () => {
const regexp = new RegExp(`^${NUMBER}$`);
const regexp = new RegExp(`^${NUMBER}$`);
expect(regexp.test(`${5}`)).toBe(true);
expect(regexp.test(`${-123}`)).toBe(true);
expect(regexp.test(`${-0}`)).toBe(true);
expect(regexp.test(`${+0}`)).toBe(true);
expect(regexp.test(`${-9.5}`)).toBe(false);
expect(regexp.test(`${13.5}`)).toBe(false);
})
});
10 changes: 2 additions & 8 deletions src/localize/formatters/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { isRange, StatValue } from '../../types/StatValue';
import Formatter from './Formatter';
import mod_value_to_item_class from './mod_value_to_item_class';
import per_minute_to_per_second from './per_minute_to_per_second';
import { NUMBER } from './regexp_util';
import { default as mod_value_to_item_class } from './mod_value_to_item_class';
import { default as per_minute_to_per_second } from './per_minute_to_per_second';

const f: Formatter = {
format: n => `${n}`,
inverse: s => +s,
regexp: NUMBER
};

/*
* rule of thumb: is the formatter self explanatory and only need
Expand Down
2 changes: 1 addition & 1 deletion src/localize/formatters/regexp_util.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const NUMBER = '-?\\d+';
export const NUMBER = '-?\\d+';
1 change: 0 additions & 1 deletion src/translate/__tests__/asRegexp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Translation } from '../../types/StatDescription';
import NamedGroupsRegexp from '../../util/NamedGroupsRegexp';
import asRegexp from '../asRegexp';
import printf from '../printf';

Expand Down
25 changes: 17 additions & 8 deletions src/types/__tests__/LocaleData.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// tslint:disable:no-unused-variable
import * as LocaleData from '../LocaleData';

// we only want to check typings so we dont actually run this test
// but verify it with ts (build:verify)
describe.skip('type definitions matching json files in locale-data', () => {
/**
* courtesy of https://github.com/Microsoft/TypeScript/issues/12936#issuecomment-368244671
*
*
* allows an exact match between T and X
* usually assiging X to T would be fine because X extends T
* but we want to make sure in our type definitions that we caught all possible
* but we want to make sure in our type definitions that we caught all possible
* fields.
*/
type Exactify<T, X extends T> = T & {
[K in keyof X]: K extends keyof T ? Exactify<T[K], X[K]> : never
}
type Exactify<T, X extends T> = T &
{ [K in keyof X]: K extends keyof T ? Exactify<T[K], X[K]> : never };

// eps1lon: going with dynamic here so that ts-jest does not transpile
// and require the hole json despite no test actually runs here
Expand Down Expand Up @@ -44,7 +44,10 @@ describe.skip('type definitions matching json files in locale-data', () => {
});
test('CharacterStartStates', async () => {
const json = await import('../../../locale-data/en/CharacterStartStates.json');
const checked: Exactify<LocaleData.CharacterStartStates, typeof json> = json;
const checked: Exactify<
LocaleData.CharacterStartStates,
typeof json
> = json;
});
test('Chests', async () => {
const json = await import('../../../locale-data/en/Chests.json');
Expand All @@ -56,7 +59,10 @@ describe.skip('type definitions matching json files in locale-data', () => {
});
test('CraftingBenchOptions', async () => {
const json = await import('../../../locale-data/en/CraftingBenchOptions.json');
const checked: Exactify<LocaleData.CraftingBenchOptions, typeof json> = json;
const checked: Exactify<
LocaleData.CraftingBenchOptions,
typeof json
> = json;
});
test('CurrencyItems', async () => {
const json = await import('../../../locale-data/en/CurrencyItems.json');
Expand Down Expand Up @@ -136,7 +142,10 @@ describe.skip('type definitions matching json files in locale-data', () => {
});
test('WarbandsPackMonsters', async () => {
const json = await import('../../../locale-data/en/WarbandsPackMonsters.json');
const checked: Exactify<LocaleData.WarbandsPackMonsters, typeof json> = json;
const checked: Exactify<
LocaleData.WarbandsPackMonsters,
typeof json
> = json;
});
test('WorldAreas', async () => {
const json = await import('../../../locale-data/en/WorldAreas.json');
Expand Down

0 comments on commit 4ab5548

Please sign in to comment.