improve prettier and lint config and performance

This commit is contained in:
Tobias Koppers 2018-08-24 16:57:16 +02:00
parent 6e01fd5099
commit 1b886ee342
14 changed files with 89 additions and 199 deletions

View File

@ -8,10 +8,6 @@ trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80
[.prettierrc]
indent_style = space
indent_size = 2
[*.{yml,yaml,json}]
indent_style = space
indent_size = 2

View File

@ -1,7 +1,11 @@
module.exports = {
root: true,
plugins: ["prettier", "node", "jest"],
extends: ["eslint:recommended", "plugin:node/recommended", "plugin:prettier/recommended"],
extends: [
"eslint:recommended",
"plugin:node/recommended",
"plugin:prettier/recommended"
],
env: {
node: true,
es6: true
@ -16,8 +20,8 @@ module.exports = {
"no-template-curly-in-string": "error",
"no-caller": "error",
"no-control-regex": "off",
"yoda": "error",
"eqeqeq": "error",
yoda: "error",
eqeqeq: "error",
"global-require": "off",
"brace-style": "error",
"eol-last": "error",
@ -27,23 +31,26 @@ module.exports = {
"no-unused-vars": ["error", { args: "none" }],
"no-unsafe-negation": "error",
"no-loop-func": "warn",
"indent": "off",
indent: "off",
"no-console": "off",
"valid-jsdoc": ["error", {
"prefer": {
"return": "returns",
"prop": "property",
"memberof": "DONTUSE",
"class": "DONTUSE",
"inheritdoc": "DONTUSE",
"description": "DONTUSE",
"readonly": "DONTUSE"
},
"preferType": {
"*": "any"
},
"requireReturnType": true
}],
"valid-jsdoc": [
"error",
{
prefer: {
return: "returns",
prop: "property",
memberof: "DONTUSE",
class: "DONTUSE",
inheritdoc: "DONTUSE",
description: "DONTUSE",
readonly: "DONTUSE"
},
preferType: {
"*": "any"
},
requireReturnType: true
}
],
"node/no-unsupported-features": "error",
"node/no-deprecated-api": "error",
"node/no-missing-import": "error",

View File

@ -1,16 +1,8 @@
# Ignore all paths.
**/*.*
# Enable prettier for the following paths.
!*.{ts,js,json}
!setup/**/*.js
!lib/**/*.js
!bin/*.js
!hot/*.js
!buildin/*.js
!benchmark/**/*.js
# Ignore test fixtures
test
!test/*.js
!tooling/*.js
!test/**/webpack.config.js
# Ignore example fixtures
examples
!examples/**/webpack.config.js
!schemas/**/*.js

View File

@ -1,5 +1,13 @@
module.exports = {
printWidth: 80,
useTabs: true,
tabWidth: 2
tabWidth: 2,
overrides: [
{
files: "*.json",
options: {
useTabs: false
}
}
]
};

View File

@ -120,10 +120,10 @@
"pretest": "yarn lint",
"prelint": "yarn setup",
"lint": "yarn code-lint && yarn schema-lint && yarn type-lint",
"code-lint": "eslint --cache setup lib bin hot buildin benchmark tooling \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\"",
"code-lint": "eslint --cache \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
"type-lint": "tsc --pretty",
"fix": "yarn code-lint --fix",
"pretty": "prettier --write \"*.{ts,js,json}\" \"setup/**/*.js\" \"lib/**/*.js\" \"bin/*.js\" \"hot/*.js\" \"buildin/*.js\" \"benchmark/**/*.js\" \"tooling/*.js\" \"test/*.js\" \"test/**/webpack.config.js\" \"examples/**/webpack.config.js\" \"schemas/**/*.js\"",
"pretty": "prettier --loglevel warn --write \"*.{ts,js,json}\" \"{setup,lib,bin,hot,buildin,benchmark,tooling,schemas}/**/*.{js,json}\" \"test/*.js\" \"test/{configCases,watchCases,statsCases,hotCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
"schema-lint": "node --max-old-space-size=4096 node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.lint.js\" --no-verbose",
"benchmark": "node --max-old-space-size=4096 --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.benchmark.js\" --runInBand",
"cover": "yarn cover:init && yarn cover:all && yarn cover:report",

View File

@ -11,9 +11,7 @@
}
},
"additionalProperties": true,
"required": [
"apply"
]
"required": ["apply"]
},
"common.pluginObject": {
"description": "Plugin instance",
@ -25,9 +23,7 @@
}
},
"additionalProperties": true,
"required": [
"apply"
]
"required": ["apply"]
},
"common.arrayOfStringOrStringArrayValues": {
"items": {
@ -339,19 +335,11 @@
},
"crossOriginLoading": {
"description": "This option enables cross-origin loading of chunks.",
"enum": [
false,
"anonymous",
"use-credentials"
]
"enum": [false, "anonymous", "use-credentials"]
},
"jsonpScriptType": {
"description": "This option enables loading async chunks via a custom script type, such as script type=\"module\"",
"enum": [
false,
"text/javascript",
"module"
]
"enum": [false, "text/javascript", "module"]
},
"chunkLoadTimeout": {
"description": "Number of milliseconds before chunk request expires",
@ -837,10 +825,7 @@
"properties": {
"enforce": {
"description": "Enforce this rule as pre or post step",
"enum": [
"pre",
"post"
]
"enum": ["pre", "post"]
},
"exclude": {
"description": "Shortcut for resource.exclude",
@ -1114,11 +1099,7 @@
"properties": {
"mode": {
"description": "Enable production optimizations or development hints.",
"enum": [
"development",
"production",
"none"
]
"enum": ["development", "production", "none"]
},
"amd": {
"description": "Set the value of `require.amd` and `define.amd`."
@ -1164,9 +1145,7 @@
"type": "string"
},
{
"enum": [
false
]
"enum": [false]
}
]
},
@ -1206,52 +1185,29 @@
"description": "Include polyfills or mocks for various node stuff.",
"anyOf": [
{
"enum": [
false
]
"enum": [false]
},
{
"additionalProperties": {
"description": "Include a polyfill for the node.js module",
"enum": [
false,
true,
"mock",
"empty"
]
"enum": [false, true, "mock", "empty"]
},
"properties": {
"Buffer": {
"description": "Include a polyfill for the 'Buffer' variable",
"enum": [
false,
true,
"mock"
]
"enum": [false, true, "mock"]
},
"__dirname": {
"description": "Include a polyfill for the '__dirname' variable",
"enum": [
false,
true,
"mock"
]
"enum": [false, true, "mock"]
},
"__filename": {
"description": "Include a polyfill for the '__filename' variable",
"enum": [
false,
true,
"mock"
]
"enum": [false, true, "mock"]
},
"console": {
"description": "Include a polyfill for the 'console' variable",
"enum": [
false,
true,
"mock"
]
"enum": [false, true, "mock"]
},
"global": {
"description": "Include a polyfill for the 'global' variable",
@ -1259,11 +1215,7 @@
},
"process": {
"description": "Include a polyfill for the 'process' variable",
"enum": [
false,
true,
"mock"
]
"enum": [false, true, "mock"]
}
},
"type": "object"
@ -1323,9 +1275,7 @@
"description": "Optimize duplication and caching by splitting chunks by shared modules and cache group",
"oneOf": [
{
"enum": [
false
]
"enum": [false]
},
{
"type": "object",
@ -1335,11 +1285,7 @@
"description": "Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML)",
"oneOf": [
{
"enum": [
"initial",
"async",
"all"
]
"enum": ["initial", "async", "all"]
},
{
"instanceof": "Function"
@ -1428,9 +1374,7 @@
"description": "Configuration for a cache group",
"anyOf": [
{
"enum": [
false
]
"enum": [false]
},
{
"instanceof": "Function"
@ -1463,11 +1407,7 @@
"description": "Select chunks for determining cache group content (defaults to \"initial\", \"initial\" and \"all\" requires adding these chunks to the HTML)",
"oneOf": [
{
"enum": [
"initial",
"async",
"all"
]
"enum": ["initial", "async", "all"]
},
{
"instanceof": "Function"
@ -1555,10 +1495,7 @@
"type": "boolean"
},
{
"enum": [
"single",
"multiple"
]
"enum": ["single", "multiple"]
},
{
"type": "object",
@ -1593,24 +1530,11 @@
},
"moduleIds": {
"description": "Define the algorithm to choose module ids (natural: numeric ids in order of usage, named: readable ids for better debugging, hashed: short hashes as ids for better long term caching, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)",
"enum": [
"natural",
"named",
"hashed",
"size",
"total-size",
false
]
"enum": ["natural", "named", "hashed", "size", "total-size", false]
},
"chunkIds": {
"description": "Define the algorithm to choose chunk ids (named: readable ids for better debugging, size: numeric ids focused on minimal initial download size, total-size: numeric ids focused on minimal total download size, false: no algorithm used, as custom one can be provided via plugin)",
"enum": [
"natural",
"named",
"size",
"total-size",
false
]
"enum": ["natural", "named", "size", "total-size", false]
},
"namedModules": {
"description": "Use readable module identifiers for better debugging (deprecated, used moduleIds: named instead)",
@ -1651,9 +1575,7 @@
"description": "Set process.env.NODE_ENV to a specific value",
"anyOf": [
{
"enum": [
false
]
"enum": [false]
},
{
"type": "string"
@ -1671,9 +1593,7 @@
"description": "Configuration for web performance recommendations.",
"anyOf": [
{
"enum": [
false
]
"enum": [false]
},
{
"additionalProperties": false,
@ -1684,11 +1604,7 @@
},
"hints": {
"description": "Sets the format of the hints: warnings, errors or nothing at all",
"enum": [
false,
"warning",
"error"
]
"enum": [false, "warning", "error"]
},
"maxEntrypointSize": {
"description": "Total size of an entry point (in bytes)",

View File

@ -34,9 +34,7 @@
{
"type": "object",
"additionalProperties": false,
"required": [
"banner"
],
"required": ["banner"],
"properties": {
"banner": {
"description": "Specifies the banner",

View File

@ -1,8 +1,6 @@
{
"additionalProperties": false,
"required": [
"path"
],
"required": ["path"],
"properties": {
"context": {
"description": "Context of requests in the manifest file (defaults to the webpack context)",

View File

@ -2,14 +2,10 @@
"additionalProperties": false,
"anyOf": [
{
"required": [
"manifest"
]
"required": ["manifest"]
},
{
"required": [
"content"
]
"required": ["content"]
}
],
"properties": {
@ -60,10 +56,7 @@
},
"type": {
"description": "The way how the export of the dll bundle is used",
"enum": [
"require",
"object"
]
"enum": ["require", "object"]
},
"scope": {
"description": "Prefix which is used for accessing the content of the dll",

View File

@ -9,11 +9,7 @@
},
"hashDigest": {
"description": "The encoding to use when generating the hash, defaults to 'base64'. All encodings from Node.JS' hash.digest are supported.",
"enum": [
"hex",
"latin1",
"base64"
]
"enum": ["hex", "latin1", "base64"]
},
"hashDigestLength": {
"description": "The prefix length of the hash digest to use, defaults to 4.",

View File

@ -62,10 +62,7 @@
"oneOf": [
{
"description": "Disable separate SourceMap file and inline SourceMap as DataUrl",
"enum": [
false,
null
]
"enum": [false, null]
},
{
"type": "string",
@ -79,10 +76,7 @@
"oneOf": [
{
"description": "Append no SourceMap comment to the bundle, but still generate SourceMaps",
"enum": [
false,
null
]
"enum": [false, null]
},
{
"minLength": 1,

View File

@ -1,9 +1,7 @@
{
"additionalProperties": false,
"type": "object",
"required": [
"minChunkSize"
],
"required": ["minChunkSize"],
"properties": {
"minChunkSize": {
"description": "Minimum number of characters",

View File

@ -28,12 +28,6 @@ describe("Schemas", () => {
});
if (content) {
it("should be formated correctly", () => {
expect(fileContent.replace(/\r\n?/g, "\n")).toBe(
JSON.stringify(content, 0, 2) + "\n"
);
});
const arrayProperties = ["oneOf", "anyOf", "allOf"];
const allowedProperties = [
"definitions",

View File

@ -1,16 +1,16 @@
{
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"lib": ["es2017", "dom"],
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": false,
"noImplicitThis": true,
"alwaysStrict": true,
"types": ["node"],
"esModuleInterop": true
},
"include": ["declarations.d.ts", "bin/*.js", "lib/**/*.js", "tooling/**/*.js"]
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"lib": ["es2017", "dom"],
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": false,
"noImplicitThis": true,
"alwaysStrict": true,
"types": ["node"],
"esModuleInterop": true
},
"include": ["declarations.d.ts", "bin/*.js", "lib/**/*.js", "tooling/**/*.js"]
}