mirror of https://github.com/zulip/zulip.git
typescript: Fix violations of existing eslint rules.
This commit is contained in:
parent
fa0a5ecb33
commit
ea9a74fe24
|
@ -38,10 +38,11 @@ export class Dict<K, V> {
|
|||
throw new TypeError("Cannot convert argument to Dict");
|
||||
}
|
||||
|
||||
let dict = new Dict<string, V>(opts);
|
||||
for (const key in obj) {
|
||||
dict.set(key, obj[key]);
|
||||
}
|
||||
const dict = new Dict<string, V>(opts);
|
||||
_.each(obj, function (val: V, key: string) {
|
||||
dict.set(key, val);
|
||||
});
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
@ -56,7 +57,7 @@ export class Dict<K, V> {
|
|||
throw new TypeError("Argument is not an array");
|
||||
}
|
||||
|
||||
let dict = new Dict<K, V | true>(opts);
|
||||
const dict = new Dict<K, V | true>(opts);
|
||||
for (const key of arr) {
|
||||
dict.set(key, true);
|
||||
}
|
||||
|
@ -67,14 +68,14 @@ export class Dict<K, V> {
|
|||
private _munge(key: K): string | undefined {
|
||||
if (key === undefined) {
|
||||
blueslip.error("Tried to call a Dict method with an undefined key.");
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
let str_key = ':' + key.toString();
|
||||
const str_key = ':' + key.toString();
|
||||
return this._fold_case ? str_key.toLowerCase() : str_key;
|
||||
}
|
||||
|
||||
clone(): Dict<K, V> {
|
||||
let dict = new Dict<K, V>({fold_case: this._fold_case});
|
||||
const dict = new Dict<K, V>({fold_case: this._fold_case});
|
||||
dict._items = { ...this._items };
|
||||
return dict;
|
||||
}
|
||||
|
@ -82,7 +83,7 @@ export class Dict<K, V> {
|
|||
get(key: K): V | undefined {
|
||||
const mapping = this._items[this._munge(key)];
|
||||
if (mapping === undefined) {
|
||||
return undefined;
|
||||
return;
|
||||
}
|
||||
return mapping.v;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ interface importLoaderOptions {
|
|||
args: string;
|
||||
}
|
||||
function getImportLoaders(optionsArr:Array<importLoaderOptions>) {
|
||||
let importsLoaders = [];
|
||||
const importsLoaders = [];
|
||||
for (var loaderEntry of optionsArr) {
|
||||
importsLoaders.push({
|
||||
test: require.resolve(loaderEntry.path),
|
||||
use: "imports-loader?" + loaderEntry.args
|
||||
use: "imports-loader?" + loaderEntry.args,
|
||||
});
|
||||
}
|
||||
return importsLoaders;
|
||||
|
@ -39,11 +39,11 @@ interface exportLoaderOptions {
|
|||
name?: string | Array<string>;
|
||||
}
|
||||
function getExposeLoaders(optionsArr:Array<exportLoaderOptions>) {
|
||||
let exposeLoaders = [];
|
||||
const exposeLoaders = [];
|
||||
for (var loaderEntry of optionsArr) {
|
||||
let path = loaderEntry.path;
|
||||
const path = loaderEntry.path;
|
||||
let name = "";
|
||||
let useArr = [];
|
||||
const useArr = [];
|
||||
// If no name is provided, infer it
|
||||
if (!loaderEntry.name) {
|
||||
name = basename(path, '.js');
|
||||
|
@ -52,7 +52,7 @@ function getExposeLoaders( optionsArr:Array<exportLoaderOptions> ) {
|
|||
// If name is an array
|
||||
if (Array.isArray(loaderEntry.name)) {
|
||||
for (var exposeName of loaderEntry.name) {
|
||||
useArr.push({loader: 'expose-loader', options: exposeName})
|
||||
useArr.push({loader: 'expose-loader', options: exposeName});
|
||||
}
|
||||
// If name is a string
|
||||
} else {
|
||||
|
@ -61,12 +61,12 @@ function getExposeLoaders( optionsArr:Array<exportLoaderOptions> ) {
|
|||
}
|
||||
exposeLoaders.push({
|
||||
test: require.resolve(path),
|
||||
use: useArr
|
||||
use: useArr,
|
||||
});
|
||||
}
|
||||
return exposeLoaders;
|
||||
}
|
||||
export {
|
||||
getExposeLoaders,
|
||||
getImportLoaders
|
||||
}
|
||||
getImportLoaders,
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ function getHotCSS(bundle:any[], isProd:boolean) {
|
|||
|
||||
export default (env?: string) : webpack.Configuration => {
|
||||
const production: boolean = env === "production";
|
||||
let config: webpack.Configuration = {
|
||||
const config: webpack.Configuration = {
|
||||
mode: production ? "production" : "development",
|
||||
context: resolve(__dirname, "../"),
|
||||
entry: assets,
|
||||
|
@ -29,8 +29,8 @@ export default (env?: string) : webpack.Configuration => {
|
|||
test: /\.tsx?$/,
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
configFile: require.resolve('../static/js/tsconfig.json')
|
||||
}
|
||||
configFile: require.resolve('../static/js/tsconfig.json'),
|
||||
},
|
||||
},
|
||||
// Uses script-loader on minified files so we don't change global variables in them.
|
||||
// Also has the effect of making processing these files fast
|
||||
|
@ -49,10 +49,10 @@ export default (env?: string) : webpack.Configuration => {
|
|||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
], production)
|
||||
], production),
|
||||
},
|
||||
// sass / scss loader
|
||||
{
|
||||
|
@ -62,15 +62,15 @@ export default (env?: string) : webpack.Configuration => {
|
|||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
}
|
||||
sourceMap: true,
|
||||
},
|
||||
},
|
||||
], production),
|
||||
},
|
||||
// load fonts and files
|
||||
|
@ -80,10 +80,10 @@ export default (env?: string) : webpack.Configuration => {
|
|||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '[name].[ext]',
|
||||
outputPath: 'files/'
|
||||
}
|
||||
}]
|
||||
}
|
||||
outputPath: 'files/',
|
||||
},
|
||||
}],
|
||||
},
|
||||
],
|
||||
},
|
||||
output: {
|
||||
|
@ -111,8 +111,8 @@ export default (env?: string) : webpack.Configuration => {
|
|||
var importsOptions = [
|
||||
{
|
||||
path: "../static/third/spectrum/spectrum.js",
|
||||
args: "this=>window"
|
||||
}
|
||||
args: "this=>window",
|
||||
},
|
||||
];
|
||||
config.module.rules.push(...getImportLoaders(importsOptions));
|
||||
|
||||
|
@ -136,7 +136,7 @@ export default (env?: string) : webpack.Configuration => {
|
|||
{ path: "../node_modules/handlebars/dist/handlebars.runtime.js", name: 'Handlebars' },
|
||||
{ path: "../node_modules/to-markdown/dist/to-markdown.js", name: 'toMarkdown' },
|
||||
{ path: "../node_modules/sortablejs/Sortable.js"},
|
||||
{ path: "../node_modules/winchan/winchan.js", name: 'WinChan'}
|
||||
{ path: "../node_modules/winchan/winchan.js", name: 'WinChan'},
|
||||
];
|
||||
config.module.rules.push(...getExposeLoaders(exposeOptions));
|
||||
|
||||
|
@ -154,12 +154,12 @@ export default (env?: string) : webpack.Configuration => {
|
|||
}
|
||||
return '[name].[contenthash].css';
|
||||
},
|
||||
chunkFilename: "[chunkhash].css"
|
||||
})
|
||||
chunkFilename: "[chunkhash].css",
|
||||
}),
|
||||
];
|
||||
} else {
|
||||
// Out JS debugging tools
|
||||
config.entry['common'].push('./static/js/debug.js');
|
||||
config.entry['common'].push('./static/js/debug.js'); // eslint-disable-line dot-notation
|
||||
|
||||
config.output.publicPath = '/webpack/';
|
||||
config.plugins = [
|
||||
|
@ -171,15 +171,15 @@ export default (env?: string) : webpack.Configuration => {
|
|||
// Extract CSS from files
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "[name].css",
|
||||
chunkFilename: "[chunkhash].css"
|
||||
chunkFilename: "[chunkhash].css",
|
||||
}),
|
||||
];
|
||||
config.devServer = {
|
||||
clientLogLevel: "error",
|
||||
stats: "errors-only",
|
||||
watchOptions: {
|
||||
poll: 100
|
||||
}
|
||||
poll: 100,
|
||||
},
|
||||
};
|
||||
}
|
||||
return config;
|
||||
|
|
Loading…
Reference in New Issue