diff --git a/.editorconfig b/.editorconfig index 934a549..6b974a4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,10 +3,15 @@ # top-most EditorConfig file root = true +# Option for setting a maximum length for each line +# Supported By A Limited Number of Editors +# https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#supported-by-a-limited-number-of-editors +[*] +max_line_length = 120 + # Unix-style newlines with a newline ending every file -# Use git.core.crlf instead -# [*] -# end_of_line = lf +[*] +end_of_line = lf # Matches multiple files with brace expansion notation # Set default charset @@ -22,3 +27,8 @@ indent_size = 4 [*.{json,yml}] indent_style = space indent_size = 2 + +# Configration files +[.*] +indent_style = space +indent_size = 2 diff --git a/.prettierignore b/.prettierignore index b623714..74990a4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,8 @@ -dist/**/* demo/**/* +dist/**/* +coverage/**/* node_modules/**/* + +# ignore root configration files +*.json +*.yml diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..dc42ba7 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,7 @@ +# Use `.editorconfig` instead. +# tabWidth: 4 +# printWidth: 120 + +# Explicit specifiy `singleQuote` value +singleQuote: false +trailingComma: all diff --git a/package.json b/package.json index e38c5ef..815232b 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,9 @@ "browser": "dist/release/fullscreen.js", "types": "src/index.ts", "scripts": { - "build": "npm run tslint && webpack --mode=production --devtool=source-map", + "build": "webpack --mode=production --devtool=source-map", "start": "webpack -w --mode=development --devtool=cheap-module-eval-source-map", "tslint": "tslint -p ./ \"./**/*.ts\" \"./**/*.tsx\"", - "pretty": "prettier --write \"./{docs,src,test,types}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"", "version": "npm run build && git add -A dist" }, "repository": { @@ -34,23 +33,22 @@ "pre-push": "npm run tslint" } }, - "prettier": { - "printWidth": 120 - }, "devDependencies": { "@types/node": "10.9.4", - "event-hooks-webpack-plugin": "2.1.0", + "event-hooks-webpack-plugin": "2.1.1", "git-rev-sync": "1.12.0", - "husky": "1.0.0-rc.13", - "prettier": "1.14.2", - "pretty-quick": "1.6.0", + "husky": "1.1.4", + "prettier": "1.15.2", + "pretty-quick": "1.8.0", "rimraf": "2.6.2", - "ts-loader": "5.0.0", + "ts-loader": "5.3.0", "tslint": "5.11.0", - "typescript": "3.0.3", - "uglifyjs-webpack-plugin": "1.3.0", - "webpack": "4.16.3", - "webpack-bundle-analyzer": "2.13.1", - "webpack-cli": "3.1.0" + "tslint-config-prettier": "1.16.0", + "tslint-plugin-prettier": "2.0.1", + "typescript": "3.1.6", + "uglifyjs-webpack-plugin": "2.0.1", + "webpack": "4.25.1", + "webpack-bundle-analyzer": "3.0.3", + "webpack-cli": "3.1.2" } } diff --git a/tsconfig.json b/tsconfig.json index 95e81c6..3f4c569 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,8 +15,21 @@ "outDir": "./dist/out-tsc", "moduleResolution": "node", "target": "es5", - "typeRoots": ["node_modules/@types"], - "lib": ["dom", "scripthost", "esnext"] + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "dom", + "scripthost", + "esnext" + ] }, - "exclude": ["node_modules"] + "include": [ + "src/**/*.ts", + "test/**/*.ts", + "types/**/*.ts" + ], + "exclude": [ + "node_modules" + ] } diff --git a/tslint.json b/tslint.json index dd07628..24330e8 100644 --- a/tslint.json +++ b/tslint.json @@ -1,24 +1,57 @@ { "linterOptions": { - "exclude": ["node_modules/**", "demo/**"] + "exclude": [ + "node_modules/**", + "coverage/**", + "demo/**", + "dist/**" + ] }, + "extends": [ + "tslint-config-prettier" + ], + "rulesDirectory": [ + "tslint-plugin-prettier" + ], "rules": { - "member-ordering": [ + "prettier": { + "severity": "warning" + }, + "member-ordering": { + "options": [ + { + "order": [ + "static-field", + "instance-field", + "constructor", + "static-method", + "instance-method" + ] + } + ], + "severity": "warning" + }, + "no-inferrable-types": [ true, - { - "order": ["static-field", "instance-field", "constructor", "static-method", "instance-method"] - } + "ignore-params", + "ignore-properties" ], - "no-inferrable-types": [true, "ignore-params", "ignore-properties"], "no-internal-module": true, - "no-namespace": [true, "allow-declarations"], + "no-namespace": [ + true, + "allow-declarations" + ], "no-non-null-assertion": true, "typedef": true, "unified-signatures": true, "ban-comma-operator": true, "label-position": true, "no-arg": true, + "no-console": { + "severity": "warning" + }, "no-construct": true, + "no-debugger": true, "no-duplicate-super": true, "no-duplicate-switch-case": true, "no-eval": true, @@ -30,26 +63,49 @@ "no-this-assignment": [ true, { - "allowed-names": ["^that$"], + "allowed-names": [ + "^that$" + ], "allow-destructuring": true } ], "no-unsafe-finally": true, "no-var-keyword": true, "radix": true, - "triple-equals": [true, "allow-null-check"], + "triple-equals": [ + true, + "allow-null-check" + ], "use-isnan": true, - "deprecation": true, - "max-file-line-count": [true, 2000], - "no-duplicate-imports": true, + "deprecation": { + "severity": "warning" + }, + "max-file-line-count": { + "options": [ + 2400 + ], + "severity": "warning" + }, + "no-duplicate-imports": { + "severity": "warning" + }, "no-require-imports": true, "callable-types": true, "class-name": true, "interface-over-type-literal": true, "new-parens": true, "no-boolean-literal-compare": true, - "no-consecutive-blank-lines": [true, 2], - "number-literal-format": true, - "variable-name": [true, "check-format"] + "no-consecutive-blank-lines": [ + true, + 2 + ], + "number-literal-format": { + "severity": "warning" + }, + "variable-name": [ + true, + "ban-keywords", + "check-format" + ] } } diff --git a/webpack.config.js b/webpack.config.js index a4babfd..1d88c3c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -36,7 +36,7 @@ module.exports = function(env = {}, argv = {}) { return { mode: env.mode, entry: { - fullscreen: "./src/index.ts" + fullscreen: "./src/index.ts", }, devtool: env.devtool, module: { @@ -47,44 +47,42 @@ module.exports = function(env = {}, argv = {}) { loader: "ts-loader", options: { compilerOptions: { - module: "esnext" - } - } - } - } - ] + module: "esnext", + }, + }, + }, + }, + ], }, output: { path: env.outputPath, filename: "[name].js", - libraryTarget: "umd" + libraryTarget: "umd", }, resolve: { - extensions: [".tsx", ".ts", ".jsx", ".js"] + extensions: [".tsx", ".ts", ".jsx", ".js"], }, plugins: [ - new webpack.ProgressPlugin((percentage, message) => { - console.log(`${(percentage * 100).toFixed()}% ${message}`); - }), + new webpack.ProgressPlugin(), new webpack.DefinePlugin({ __X_METADATA__: JSON.stringify({ name: manifest.name, version: manifest.version, envMode: env.mode, gitHash: git.short(), - lastCompiled: env.lastCompiled - }) + lastCompiled: env.lastCompiled, + }), }), new EventHooksPlugin({ environment: function() { rimraf.sync(webpackPath); rimraf.sync(releasePath); - } + }, }), new BundleAnalyzerPlugin({ analyzerMode: env.mode === "production" ? "static" : "disabled", - openAnalyzer: false - }) + openAnalyzer: false, + }), ], optimization: { minimizer: [ @@ -94,22 +92,22 @@ module.exports = function(env = {}, argv = {}) { uglifyOptions: { compress: { drop_console: false, - drop_debugger: true + drop_debugger: true, }, output: { /** * @desc escape Unicode characters in strings and regexps * (affects directives with non-ascii characters becoming invalid) */ - ascii_only: false - } - } - }) - ] + ascii_only: false, + }, + }, + }), + ], }, node: false, performance: { - hints: false - } + hints: false, + }, }; };