Skip to content

Commit

Permalink
Move lint config to shared package (#2387)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Jan 16, 2022
1 parent 4bc7587 commit e5274d9
Show file tree
Hide file tree
Showing 19 changed files with 227 additions and 437 deletions.
94 changes: 13 additions & 81 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,22 @@
const contexts = [
"background",
"contentScript",
"devTools",
"options",
"actionPanel",
"pageScript",
];

const restrictedZones = [];
for (const exporter of contexts) {
for (const importer of contexts) {
if (exporter !== importer) {
restrictedZones.push({
target: `./src/${importer}/**/*`,
from: `./src/${exporter}`,
except: [`../${exporter}/messenger/api.ts`],
});
}
}
}

module.exports = {
root: true,
extends: [
// Full config: https://github.com/fregante/eslint-config-pixiebrix/blob/main/index.js
"pixiebrix",
],
rules: {
"import/dynamic-import-chunkname": [
"error",
{
webpackChunknameFormat: "[a-zA-Z0-57-9-/_\\[\\].]+",
},
],
"unicorn/prevent-abbreviations": [
"error",
{
replacements: {
acc: false,
arg: false,
args: false,
db: false,
dev: false,
doc: false,
docs: false,
env: false,
err: false,
ev: false,
evt: false,
ext: false,
exts: false,
fn: false,
func: {
fn: true,
function: false,
},
i: false,
j: false,
num: false,
obj: false,
param: false,
params: false,
prev: false,
prod: false,
prop: false,
props: false,
ref: false,
refs: false,
str: false,
var: false,
vars: false,
},
ignore: ["semVer", "SemVer"],
},
],
"import/no-restricted-paths": [
"warn",
{
zones: restrictedZones,
},
],

// Incorrectly suggests to use `runtime.sendMessage` instead of `browser.runtime.sendMessage`
"import/no-named-as-default-member": "off",

// Sometimes it conflicts with Prettier
"unicorn/no-nested-ternary": "off",
// TODO: The rule is currently broken, it should accept `throw unknown` but doesn't
"@typescript-eslint/no-throw-literal": "off",

// TODO: Import extended config from app, after improving it
"@typescript-eslint/naming-convention": "off",

// The rule is unreasonably slow (90 sec lint -> 5 minutes)
// https://github.com/pixiebrix/pixiebrix-extension/issues/1080
"import/no-cycle": "off",

// Rules that depend on https://github.com/pixiebrix/pixiebrix-extension/issues/775
"@typescript-eslint/no-explicit-any": "warn",
Expand All @@ -94,11 +25,8 @@ module.exports = {

// Rules to fix and enforce over time
"no-await-in-loop": "warn",

"unicorn/no-useless-undefined": "warn", // Buggy with React
"unicorn/consistent-function-scoping": "warn", // Complains about some of the lifted functions
"unicorn/no-await-expression-member": "warn", // Annoying sometimes, let's try it

"@typescript-eslint/consistent-type-assertions": "warn",
},
ignorePatterns: [
Expand Down Expand Up @@ -132,6 +60,10 @@ module.exports = {
jest: true,
},
extends: ["pixiebrix/server"],
rules: {
// TODO: Import extended config from app, after improving it
"@typescript-eslint/naming-convention": "off",
},
},
],
};
Loading

0 comments on commit e5274d9

Please sign in to comment.