Skip to content

Commit

Permalink
Lint dist files with eslint-plugin-compat (#11245)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Aug 16, 2021
1 parent 43124ad commit 051e205
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 11 deletions.
2 changes: 2 additions & 0 deletions cspell.json
Expand Up @@ -41,6 +41,7 @@
"Bopomofo",
"Breakell",
"Brevik",
"browserslist",
"builtins",
"callees",
"camelcase",
Expand All @@ -59,6 +60,7 @@
"codemods",
"combinator",
"commonmark",
"compat",
"concating",
"cond",
"corejs",
Expand Down
11 changes: 9 additions & 2 deletions package.json
Expand Up @@ -109,6 +109,7 @@
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-formatter-friendly": "7.0.0",
"eslint-plugin-compat": "3.11.1",
"eslint-plugin-import": "2.24.0",
"eslint-plugin-jest": "24.4.0",
"eslint-plugin-prettier-internal-rules": "2.0.1",
Expand Down Expand Up @@ -153,7 +154,7 @@
"lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
"lint:changelog": "node ./scripts/lint-changelog.mjs",
"lint:prettier": "prettier . \"!test*\" --check",
"lint:dist": "eslint --no-eslintrc --no-ignore --no-inline-config --env=es6,browser --parser-options=ecmaVersion:2019 \"dist/!(bin-prettier|index|third-party).js\"",
"lint:dist": "eslint --no-eslintrc --no-ignore --no-inline-config --config=./scripts/bundle-eslint-config.js \"dist/!(bin-prettier|index|third-party).js\"",
"lint:spellcheck": "cspell --no-progress --relative",
"lint:deps": "node ./scripts/check-deps.mjs",
"lint:actionlint": "node-actionlint",
Expand All @@ -162,5 +163,11 @@
"fix:prettier": "yarn lint:prettier --write",
"build": "node --max-old-space-size=3072 ./scripts/build/build.mjs",
"build-docs": "node ./scripts/build-docs.mjs"
}
},
"browserslist": [
">0.5%",
"not ie 11",
"not safari 5.1",
"not op_mini all"
]
}
1 change: 1 addition & 0 deletions scripts/build/build.mjs
Expand Up @@ -137,6 +137,7 @@ async function preparePackage() {
pkg.engines.node = ">=10.13.0";
delete pkg.dependencies;
delete pkg.devDependencies;
delete pkg.browserslist;
pkg.scripts = {
prepublishOnly:
"node -e \"assert.equal(require('.').version, require('..').version)\"",
Expand Down
12 changes: 4 additions & 8 deletions scripts/build/bundler.mjs
Expand Up @@ -18,8 +18,9 @@ import rollupPluginEvaluate from "./rollup-plugins/evaluate.mjs";
import rollupPluginReplaceModule from "./rollup-plugins/replace-module.mjs";
import bundles from "./config.mjs";

const { __dirname, require } = createEsmUtils(import.meta);
const { __dirname, require, json } = createEsmUtils(import.meta);
const PROJECT_ROOT = path.join(__dirname, "../..");
const packageJson = json.loadSync("../../package.json");

const entries = [
// Force using the CJS file, instead of ESM; i.e. get the file
Expand Down Expand Up @@ -79,12 +80,7 @@ function getBabelConfig(bundle) {
};
const targets = { node: "10" };
if (bundle.target === "universal") {
targets.browsers = [
">0.5%",
"not ie 11",
"not safari 5.1",
"not op_mini all",
];
targets.browsers = packageJson.browserslist;
}
config.presets = [
[
Expand Down Expand Up @@ -189,7 +185,7 @@ function getRollupConfig(bundle) {
// Replace package.json with `{version: "{VERSION}"}`
replaceModule[path.join(PROJECT_ROOT, "package.json")] = {
code: `export default ${JSON.stringify({
version: require("../../package.json").version,
version: packageJson.version,
})};`,
};

Expand Down
26 changes: 26 additions & 0 deletions scripts/bundle-eslint-config.js
@@ -0,0 +1,26 @@
"use strict";

const targets = require("../package.json").browserslist;

module.exports = {
root: true,
env: {
browser: true,
},
parserOptions: {
ecmaVersion: "latest",
},
settings: {
targets,
lintAllEsApis: true,
polyfills: [
// These are not really polyfilled, but seems safe to use in target browsers
"BigInt",
"Symbol.asyncIterator",
],
},
plugins: ["compat"],
rules: {
"compat/compat": "error",
},
};
38 changes: 37 additions & 1 deletion yarn.lock
Expand Up @@ -1464,6 +1464,11 @@
"@types/yargs" "^16.0.0"
chalk "^4.0.0"

"@mdn/browser-compat-data@^3.3.11":
version "3.3.14"
resolved "https://registry.yarnpkg.com/@mdn/browser-compat-data/-/browser-compat-data-3.3.14.tgz#b72a37c654e598f9ae6f8335faaee182bebc6b28"
integrity sha512-n2RC9d6XatVbWFdHLimzzUJxJ1KY8LdjqrW6YvGPiRmsHkhOUx74/Ct10x5Yo7bC/Jvqx7cDEW8IMPv/+vwEzA==

"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -2123,6 +2128,13 @@ array.prototype.flatmap@^1.2.4:
es-abstract "^1.18.0-next.1"
function-bind "^1.1.1"

ast-metadata-inferer@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/ast-metadata-inferer/-/ast-metadata-inferer-0.5.1.tgz#8268d68b20c03ff3dbce97c15dfa00dcac70fa5c"
integrity sha512-fj+QuB47ODy18p5gJ4BFnpenk992o7gx7oPid6oUK9+Uy/F3/5cvZ13harpQPN5Y8MlcjYf0y1LwgOV1J31k+A==
dependencies:
"@mdn/browser-compat-data" "^3.3.11"

astral-regex@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
Expand Down Expand Up @@ -2334,6 +2346,11 @@ caniuse-lite@^1.0.30001219:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001237.tgz#4b7783661515b8e7151fc6376cfd97f0e427b9e5"
integrity sha512-pDHgRndit6p1NR2GhzMbQ6CkRrp4VKuSsqbcLeOQppYPKOYkKT/6ZvZDvKJUqcmtyWIAHuZq3SVS2vc1egCZzw==

caniuse-lite@^1.0.30001245:
version "1.0.30001251"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001251.tgz#6853a606ec50893115db660f82c094d18f096d85"
integrity sha512-HOe1r+9VkU4TFmnU70z+r7OLmtR+/chB1rdcJUeQlAinjEeb0cKL20tlAtOagNZhbrtLnCvV19B4FmF1rgzl6A==

ccount@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.1.0.tgz#246687debb6014735131be8abab2d93898f8d043"
Expand Down Expand Up @@ -2547,7 +2564,7 @@ core-js-compat@^3.16.0, core-js-compat@^3.9.1:
browserslist "^4.16.6"
semver "7.0.0"

core-js@3.16.1:
core-js@3.16.1, core-js@^3.15.2:
version "3.16.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.16.1.tgz#f4485ce5c9f3c6a7cb18fa80488e08d362097249"
integrity sha512-AAkP8i35EbefU+JddyWi12AWE9f2N/qr/pwnDtWz4nyUIBGMJPX99ANFFRSw6FefM374lDujdtLDyhN2A/btHw==
Expand Down Expand Up @@ -2979,6 +2996,20 @@ eslint-module-utils@^2.6.2:
debug "^3.2.7"
pkg-dir "^2.0.0"

eslint-plugin-compat@3.11.1:
version "3.11.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-compat/-/eslint-plugin-compat-3.11.1.tgz#f95d7da1cdbb7c05c81d75fa2e1ecee266ccf4aa"
integrity sha512-iJyltnaVN9g/MYL3WGb6GFyJs+4mMkumq2E5srxsQIfPqQh14HEE0dtQC/HKDWze+hkwQtSo5DvC3IW5Gmxdtw==
dependencies:
"@mdn/browser-compat-data" "^3.3.11"
ast-metadata-inferer "^0.5.1"
browserslist "^4.16.6"
caniuse-lite "^1.0.30001245"
core-js "^3.15.2"
find-up "^5.0.0"
lodash.memoize "4.1.2"
semver "7.3.5"

eslint-plugin-import@2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.24.0.tgz#697ffd263e24da5e84e03b282f5fb62251777177"
Expand Down Expand Up @@ -4780,6 +4811,11 @@ lodash.debounce@^4.0.8:
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=

lodash.memoize@4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=

lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
Expand Down

0 comments on commit 051e205

Please sign in to comment.