Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move lint config to shared package #2387

Merged
merged 5 commits into from
Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


// 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