Skip to content

Commit

Permalink
feat: refactor lint, @factor/lint
Browse files Browse the repository at this point in the history
  • Loading branch information
arpowers committed Dec 20, 2021
1 parent d3a0216 commit dd9b7ba
Show file tree
Hide file tree
Showing 5 changed files with 324 additions and 387 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["./@core/lint/config.cjs"],
}
130 changes: 74 additions & 56 deletions .eslintrc.json → @core/lint/config.cjs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,113 +1,131 @@
{
"root": true,
"globals": {
"module": false,
"process": false,
"cy": false,
"Cypress": false,
"to": false,
"describe": false,
"context": false,
"globalThis": false
const BASIC_ONLY = process.env.LINT_ENV == "basic" ? true : false

const tsLintConfig = BASIC_ONLY
? "plugin:@typescript-eslint/recommended"
: "plugin:@typescript-eslint/recommended-requiring-type-checking"

const tsLintRules = BASIC_ONLY
? { "@typescript-eslint/explicit-module-boundary-types": "off" }
: {
"@typescript-eslint/explicit-module-boundary-types": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unsafe-argument": "warn",
}

module.exports = {
root: true,
globals: {
module: false,
process: false,
cy: false,
Cypress: false,
to: false,
describe: false,
context: false,
globalThis: false,
},
"parser": "vue-eslint-parser",
"parserOptions": {
"sourceType": "module",
"parser": "@typescript-eslint/parser",
"project": "./tsconfig.json",
"extraFileExtensions": [".vue", ".json"]
parser: "vue-eslint-parser",
parserOptions: {
sourceType: "module",
parser: "@typescript-eslint/parser",
project: "./tsconfig.json",
extraFileExtensions: [".vue", ".json", ".cjs", ".mjs"],
},
"env": {
"browser": true,
"es6": true,
"node": true
env: {
browser: true,
es6: true,
node: true,
},

"extends": [
ignorePatterns: [
"node_modules",
"**/node_modules/**",
"cdk.out/**",
"**/regex*",
"*eslint*",
],
extends: [
"plugin:unicorn/recommended",
"plugin:jest/recommended",
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
tsLintConfig,
"plugin:vue/vue3-recommended",
"prettier"
"prettier",
],

"plugins": [
plugins: [
"json",
"prettier",
"unicorn",
"import",
"jest",
"@typescript-eslint",
"implicit-dependencies"
"implicit-dependencies",
],

"rules": {
rules: {
"implicit-dependencies/no-implicit": [
"error",
{ "peer": true, "dev": true, "optional": true }
{ peer: true, dev: true, optional: true },
],
"semi": ["error", "never"],
semi: ["error", "never"],
"jest/no-disabled-tests": "off",
"jest/no-commented-out-tests": "off",
"jest/expect-expect": "off",
"no-console": "error",
"no-debugger": "error",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/no-namespace": 0,
"@typescript-eslint/ban-ts-comment": "off",
"vue/no-v-html": "off",
"no-undef": "off",
"func-style": ["warn", "expression"],
"no-async-promise-executor": "off",
"unicorn/no-abusive-eslint-disable": 0,
"unicorn/prevent-abbreviations": "off",
"unicorn/filename-case": "off",
"unicorn/prefer-ternary": "off",
"unicorn/no-nested-ternary": "off",
"unicorn/prefer-switch": "off",
"@typescript-eslint/no-empty-function": "off",

"no-async-promise-executor": "off",
"import/no-cycle": 2,
"import/no-unresolved": "off",
"import/named": "off",
"import/extensions": ["warn", "always", { "ts": "never", "js": "never" }],
"import/extensions": ["warn", "always", { ts: "never", js: "never" }],
"unicorn/prefer-module": "off",
"unicorn/no-null": "off",
"unicorn/no-fn-reference-in-iterator": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/no-array-for-each": "off",
"unicorn/prefer-node-protocol": "off",
"@typescript-eslint/explicit-module-boundary-types": "off", // come back to this later (2000 errors)
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/no-namespace": 0,
"@typescript-eslint/explicit-function-return-type": "off", // overridden for .ts files
"@typescript-eslint/no-use-before-define": "warn", // can cause organization issues
"func-style": ["warn", "expression"],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-var-requires": "off", // overridden for transpiled .ts files
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/member-delimiter-style": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{ "argsIgnorePattern": "^_" }
],
"vue/no-v-html": "off",
"no-undef": "off"
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-unsafe-assignment": "warn",
...tsLintRules,
},
"overrides": [
overrides: [
{
// enable the rule specifically for TypeScript files
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-function-return-type": ["warn"]
}
files: ["*.ts", "*.tsx"],
rules: {
"@typescript-eslint/explicit-function-return-type": ["warn"],
},
},
{
"files": "*.vue",
"rules": {
"unicorn/consistent-function-scoping": "off"
}
}
files: "*.vue",
rules: {
"unicorn/consistent-function-scoping": "off",
},
},
],

"settings": {}
settings: {},
}
27 changes: 27 additions & 0 deletions @core/lint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@factor/lint",
"version": "3.4.6",
"license": "MIT",
"main": "config.cjs",
"publishConfig": {
"access": "public"
},
"private": false,
"dependencies": {},
"devDependencies": {
"eslint": "^8.1.0",
"eslint-config-prettier": "latest",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-json": "latest",
"eslint-plugin-prettier": "latest",
"eslint-plugin-simple-import-sort": "latest",
"eslint-plugin-unicorn": "^39.0.0",
"eslint-plugin-vue": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"prettier": "^2.4.1",
"prettier-eslint": "^13.0.0"
}
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dev": "yarn workspace @factor/site factor dev",
"test": "npm run test-lint && npm run test-unit",
"test-lint": "npm run test-eslint && npm run test-types",
"test-eslint": "eslint --ext .ts,.js,.vue,.json .",
"test-eslint": "LINT_ENV=basic eslint --ext .ts,.js -c ./@core/lint/config.cjs --no-eslintrc @core/. @apps/. @plugins/.",
"test-types": "tsc --skipLibCheck --excludeDirectories node_modules",
"test-unit": "npx jest --forceExit --passWithNoTests",
"test-integration": "npx jest test/integration --forceExit --passWithNoTests",
Expand Down Expand Up @@ -72,7 +72,6 @@
"dependencies": {
"@darwin_/blog": "^3.1.12",
"autoprefixer": "^10.3.7",
"eslint-plugin-implicit-dependencies": "^1.1.0",
"postcss": "^8.3.11",
"tailwindcss": "^3.0.0",
"typescript": "^4.4.4"
Expand Down

0 comments on commit dd9b7ba

Please sign in to comment.