Skip to content

Commit

Permalink
Merge pull request #13 from apache-superset/kristw--translator-lint
Browse files Browse the repository at this point in the history
Fix lint issues in translation module
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 26, 2021
1 parent e2c83f9 commit 0981b6d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build": "yarn run build:cjs && yarn run build:esm",
"dev": "beemo babel --watch ./src --out-dir esm/ --esm",
"jest": "beemo jest --color --coverage",
"eslint": "beemo eslint \"./{src,test}/**/*.{js,jsx,json,md}\"",
"eslint": "beemo eslint \"./{src,test}/**/*.{js,jsx,md}\"",
"lint": "yarn run prettier && yarn run eslint",
"lint:fix": "yarn run prettier --write && yarn run eslint --fix",
"test": "yarn run jest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class Translator {
return input;
}
const text = this.i18n.gettext(input);
return (args.length > 0) ? sprintf(text, ...args) : text;

return args.length > 0 ? sprintf(text, ...args) : text;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ let singleton;

function configure(config) {
singleton = new Translator(config);

return singleton;
};
}

function getInstance() {
if (!singleton) {
throw new Error('You must call configure(...) before calling other methods');
}

return singleton;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ describe('Translator', () => {
expect(new Translator({})).toBeInstanceOf(Translator);
});
it('initializes when config is specified', () => {
expect(new Translator({
languagePack: languagePackZh,
})).toBeInstanceOf(Translator);
expect(
new Translator({
languagePack: languagePackZh,
}),
).toBeInstanceOf(Translator);
});
});
describe('.translate(input, ...args)', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"Copy of %s": ["%s 的副本"]
}
}
}
}

0 comments on commit 0981b6d

Please sign in to comment.