Files
test-repo/scripts/bundle-eslint-config.cjs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

117 lines
3.2 KiB
JavaScript
Raw Normal View History

2022-02-09 08:30:36 +08:00
"use strict";
const targets = require("../package.json").browserslist;
2022-10-13 17:05:20 +08:00
/* TODO[@fisker]: Fix `no-restricted-syntax` */
2022-02-09 08:30:36 +08:00
module.exports = {
root: 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"],
overrides: [
2022-10-13 17:05:20 +08:00
{
files: ["**/*"],
rules: {
"no-restricted-syntax": [
"error",
// Forbid `require()` .mjs file
{
selector:
'CallExpression[callee.name="require"][arguments.0.value=/^\\..*?\\.mjs$/]',
message: ".mjs file can't be `require()`d",
},
],
},
},
2022-02-09 08:30:36 +08:00
{
files: ["**/*.mjs"],
parserOptions: {
sourceType: "module",
},
},
{
files: [
"doc.js",
"doc.mjs",
2022-02-09 08:30:36 +08:00
"standalone.js",
"standalone.mjs",
"plugins/*",
2022-02-09 08:30:36 +08:00
],
env: {
browser: true,
},
rules: {
"compat/compat": "error",
2022-10-13 17:05:20 +08:00
// "no-restricted-syntax": [
// "error",
// // Forbid `require()`
// {
// selector: 'CallExpression[callee.name="require"]',
// message:
// "Universal bundles should not include any `require()` call.",
// },
// {
// selector: "ImportDeclaration",
// message:
// "Universal bundles should not include any `import` declaration.",
// },
// {
// selector:
// ":matches(ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration)[source]",
// message: "Universal bundles should not `export` from other files.",
// },
// {
// selector: "ImportExpression",
// message: "Universal bundles should not include any `import()`.",
// },
// ],
2022-02-09 08:30:36 +08:00
},
},
2022-03-28 09:41:08 +08:00
{
files: ["index.cjs", "index.mjs", "bin/*", "internal/*"],
2022-03-28 09:41:08 +08:00
rules: {
2022-10-13 17:05:20 +08:00
// "no-restricted-syntax": [
// "error",
// // Forbid top level `require()` parsers
// {
// selector:
// 'CallExpression:not(:function *)[callee.name="require"][arguments.0.value=/plugins/]',
// message: "Parsers should be inline `require()`d.",
// },
// // Forbid top level `import()` parsers
// {
// selector:
// "ImportExpression:not(:function *)[source.value=/plugins/]",
// message: "Parsers should be inline `import()`ed.",
// },
// // Forbid `import`/`export` parsers
// {
// selector:
// ":matches(ImportDeclaration, ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration)[source.value=/plugins/]",
// message: "Parsers should be inline `import()`ed.",
// },
// ],
2022-03-28 09:41:08 +08:00
},
},
2022-02-09 08:30:36 +08:00
{
files: ["bin/prettier.cjs"],
parserOptions: {
ecmaVersion: 5,
},
2022-02-09 08:30:36 +08:00
rules: {
"compat/compat": "error",
2022-02-09 08:30:36 +08:00
},
},
],
};