Skip to content

Commit

Permalink
chore: linter unification
Browse files Browse the repository at this point in the history
- [x] Use extended config versions of eslint and tsconfig
  • Loading branch information
0xmad authored and ctrlc03 committed Jan 8, 2024
1 parent c48e653 commit 61a8bcd
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 835 deletions.
115 changes: 99 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,107 @@
const fs = require("fs");
const path = require("path");

const prettierConfig = fs.readFileSync(path.resolve(__dirname, "./.prettierrc"), "utf8");
const prettierOptions = JSON.parse(prettierConfig);
const isProduction = process.env.NODE_ENV === "production";

module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
root: true,
extends: [
"eslint:recommended",
"airbnb",
"prettier",
"plugin:import/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/strict",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:import/typescript",
],
plugins: ["json", "prettier", "unused-imports", "import", "@typescript-eslint"],
parser: "@typescript-eslint/parser",
env: {
node: true,
mocha: true,
es2022: true,
},
settings: {
react: {
version: "999.999.999",
},
"import/resolver": {
typescript: {},
node: {
extensions: [".ts", ".js"],
moduleDirectory: ["node_modules", "ts", "src"],
},
},
},
parserOptions: {
project: path.resolve(__dirname, "./tsconfig.json"),
sourceType: "module",
typescript: true,
ecmaVersion: 2022,
experimentalDecorators: true,
requireConfigFile: false,
ecmaFeatures: {
classes: true,
impliedStrict: true,
},
warnOnUnsupportedTypeScriptVersion: true,
},
reportUnusedDisableDirectives: isProduction,
rules: {
"no-console": "off",
"no-debugger": "off",
"no-prototype-builtins": "off",
"no-constant-condition": ["error", { checkLoops: false }],
"no-empty": ["error", { allowEmptyCatch: true }],
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"import/no-cycle": ["error"],
"unused-imports/no-unused-imports": "error",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: ["**/*.test.ts"],
},
],
"no-debugger": isProduction ? "error" : "off",
"no-console": "error",
"no-underscore-dangle": "error",
"no-redeclare": ["error", { builtinGlobals: true }],
"import/order": [
"error",
{
groups: ["external", "builtin", "internal", "type", "parent", "sibling", "index", "object"],
alphabetize: {
order: "asc",
caseInsensitive: true,
},
warnOnUnassignedImports: true,
"newlines-between": "always",
},
],
"prettier/prettier": ["error", prettierOptions],
"import/prefer-default-export": "off",
"import/extensions": ["error", { json: "always" }],
"class-methods-use-this": "off",
"prefer-promise-reject-errors": "off",
"max-classes-per-file": "off",
"no-use-before-define": ["off"],
"no-shadow": "off",
curly: ["error", "all"],

"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-use-before-define": ["error", { functions: false, classes: false }],
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
"@typescript-eslint/no-shadow": [
"error",
{
builtinGlobals: true,
allow: ["location", "event", "history", "name", "status", "Option", "test", "expect"],
},
],
},
};
89 changes: 1 addition & 88 deletions circuits/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,9 @@
const fs = require("fs");
const path = require("path");

const prettierConfig = fs.readFileSync(path.resolve(__dirname, "../.prettierrc"), "utf8");
const prettierOptions = JSON.parse(prettierConfig);
const isProduction = process.env.NODE_ENV === "production";

module.exports = {
root: true,
extends: [
"airbnb",
"prettier",
"plugin:import/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/strict",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:import/typescript",
],
plugins: ["json", "prettier", "unused-imports", "import", "@typescript-eslint"],
extends: ["../.eslintrc.js"],
parser: "@typescript-eslint/parser",
env: {
node: true,
mocha: true,
es2022: true,
},
settings: {
react: {
version: "999.999.999",
},
"import/resolver": {
typescript: {},
node: {
extensions: [".ts", ".js"],
moduleDirectory: ["node_modules", "ts", "src"],
},
},
},
parserOptions: {
project: path.resolve(__dirname, "./tsconfig.json"),
sourceType: "module",
Expand All @@ -52,56 +17,4 @@ module.exports = {
},
warnOnUnsupportedTypeScriptVersion: true,
},
reportUnusedDisableDirectives: isProduction,
rules: {
"import/no-cycle": ["error"],
"unused-imports/no-unused-imports": "error",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: ["**/*.test.ts"],
},
],
"no-debugger": isProduction ? "error" : "off",
"no-console": "error",
"no-underscore-dangle": "error",
"no-redeclare": ["error", { builtinGlobals: true }],
"import/order": [
"error",
{
groups: ["external", "builtin", "internal", "type", "parent", "sibling", "index", "object"],
alphabetize: {
order: "asc",
caseInsensitive: true,
},
warnOnUnassignedImports: true,
"newlines-between": "always",
},
],
"prettier/prettier": ["error", prettierOptions],
"import/prefer-default-export": "off",
"import/extensions": ["error", { json: "always" }],
"class-methods-use-this": "off",
"prefer-promise-reject-errors": "off",
"max-classes-per-file": "off",
"no-use-before-define": ["off"],
"no-shadow": "off",
curly: ["error", "all"],

"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-use-before-define": ["error", { functions: false, classes: false }],
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
"@typescript-eslint/no-shadow": [
"error",
{
builtinGlobals: true,
allow: ["location", "event", "history", "name", "status", "Option", "test", "expect"],
},
],
},
};
28 changes: 1 addition & 27 deletions circuits/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "./build",
"declaration": true,
"allowJs": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"target": "ES2020",
"lib": ["es2020"],
"experimentalDecorators": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"skipLibCheck": true,
"esModuleInterop": true,
"isolatedModules": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"composite": true,
"incremental": true,
"declarationMap": true,
"sourceMap": true,
"stripInternal": true
"outDir": "./build"
},
"include": ["./ts"]
}
89 changes: 1 addition & 88 deletions cli/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,9 @@
const fs = require("fs");
const path = require("path");

const prettierConfig = fs.readFileSync(path.resolve(__dirname, "../.prettierrc"), "utf8");
const prettierOptions = JSON.parse(prettierConfig);
const isProduction = process.env.NODE_ENV === "production";

module.exports = {
root: true,
extends: [
"airbnb",
"prettier",
"plugin:import/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/strict",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:import/typescript",
],
plugins: ["json", "prettier", "unused-imports", "import", "@typescript-eslint"],
extends: ["../.eslintrc.js"],
parser: "@typescript-eslint/parser",
env: {
node: true,
mocha: true,
es2022: true,
},
settings: {
react: {
version: "999.999.999",
},
"import/resolver": {
typescript: {},
node: {
extensions: [".ts", ".js"],
moduleDirectory: ["node_modules", "ts", "src"],
},
},
},
parserOptions: {
project: path.resolve(__dirname, "./tsconfig.json"),
sourceType: "module",
Expand All @@ -52,56 +17,4 @@ module.exports = {
},
warnOnUnsupportedTypeScriptVersion: true,
},
reportUnusedDisableDirectives: isProduction,
rules: {
"import/no-cycle": ["error"],
"unused-imports/no-unused-imports": "error",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: ["**/*.test.ts"],
},
],
"no-debugger": isProduction ? "error" : "off",
"no-console": "error",
"no-underscore-dangle": "error",
"no-redeclare": ["error", { builtinGlobals: true }],
"import/order": [
"error",
{
groups: ["external", "builtin", "internal", "type", "parent", "sibling", "index", "object"],
alphabetize: {
order: "asc",
caseInsensitive: true,
},
warnOnUnassignedImports: true,
"newlines-between": "always",
},
],
"prettier/prettier": ["error", prettierOptions],
"import/prefer-default-export": "off",
"import/extensions": ["error", { json: "always" }],
"class-methods-use-this": "off",
"prefer-promise-reject-errors": "off",
"max-classes-per-file": "off",
"no-use-before-define": ["off"],
"no-shadow": "off",
curly: ["error", "all"],

"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-use-before-define": ["error", { functions: false, classes: false }],
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
"@typescript-eslint/no-shadow": [
"error",
{
builtinGlobals: true,
allow: ["location", "event", "history", "name", "status", "Option", "test", "expect"],
},
],
},
};
28 changes: 1 addition & 27 deletions cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "./build",
"declaration": true,
"allowJs": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"target": "ES2020",
"lib": ["es2020"],
"experimentalDecorators": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"skipLibCheck": true,
"esModuleInterop": true,
"isolatedModules": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"composite": true,
"incremental": true,
"declarationMap": true,
"sourceMap": true,
"stripInternal": true
"outDir": "./build"
},
"include": ["./ts", "./tests"],
"files": ["./hardhat.config.ts"]
Expand Down
Loading

0 comments on commit 61a8bcd

Please sign in to comment.