Skip to content

Commit

Permalink
chore: Centralise ESLint rules (medusajs#2162)
Browse files Browse the repository at this point in the history
* chore: centrilize eslint rules
  • Loading branch information
carlos-r-l-rodrigues authored Sep 13, 2022
1 parent 612a548 commit a94d981
Show file tree
Hide file tree
Showing 42 changed files with 550 additions and 725 deletions.
104 changes: 15 additions & 89 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,97 +1,23 @@
# FILES TODO

/packages/medusa/src/services/fulfillment-provider.js
/packages/medusa/src/services/middleware.js
/packages/medusa/src/subscribers/notification.js
/packages/medusa/src/subscribers/order.js
/packages/medusa/src/subscribers/product.js
/packages/medusa/src/loaders/api.ts
/packages/medusa/src/loaders/database.ts
/packages/medusa/src/loaders/defaults.ts
/packages/medusa/src/loaders/express.ts
/packages/medusa/src/loaders/index.ts
/packages/medusa/src/loaders/logger.ts
/packages/medusa/src/loaders/models.ts
/packages/medusa/src/loaders/passport.ts
/packages/medusa/src/loaders/plugins.ts
/packages/medusa/src/loaders/redis.ts
/packages/medusa/src/loaders/repositories.ts
/packages/medusa/src/loaders/services.ts
/packages/medusa/src/loaders/subscribers.ts
/packages/medusa/src/api/routes/admin/auth
/packages/medusa/src/api/routes/admin/collections
/packages/medusa/src/api/routes/store/carts
/packages/medusa/src/api/routes/store/return-reasons
/packages/medusa/src/api/routes/store/returns

# JS Client
/packages/medusa-js/src/resources/auth.ts
/packages/medusa-js/src/resources/gift-cards.ts
/packages/medusa-js/src/resources/line-items.ts
/packages/medusa-js/src/resources/payment-methods.ts
/packages/medusa-js/src/resources/product-variants.ts
/packages/medusa-js/src/resources/regions.ts
/packages/medusa-js/src/resources/return-reasons.ts
/packages/medusa-js/src/resources/returns.ts
/packages/medusa-js/src/resources/shipping-options.ts
/packages/medusa-js/src/resources/swaps.ts
/packages/medusa-js/src/resources/collections.ts
/packages/medusa-js/src/types/
/packages/medusa-js/src/error.ts


# END OF FILES TODO

/packages/medusa/src/models
/packages/medusa/src/repositories
/packages/medusa/src/commands
/packages/medusa/src/helpers
/packages/medusa/src/migrations
/packages/medusa/src/utils
/integration-tests
/docs
/docs-util
/scripts
/www
/packages/babel-preset-medusa-package
/packages/create-medusa-app
/packages/medusa-cli
/packages/medusa-core-utils
/packages/medusa-dev-cli
/packages/medusa-file-minio
/packages/medusa-file-s3
/packages/medusa-file-spaces
/packages/medusa-fulfillment-manual
/packages/medusa-fulfillment-webshipper
/packages/medusa-interfaces
/packages/medusa-payment-adyen
/packages/medusa-payment-klarna
/packages/medusa-payment-manual
/packages/medusa-payment-paypal
/packages/medusa-payment-stripe
/packages/medusa-plugin-meilisearch
/packages/medusa-plugin-add-ons
/packages/medusa-plugin-brightpearl
/packages/medusa-plugin-contentful
/packages/medusa-plugin-discount-generator
/packages/medusa-plugin-economic
/packages/medusa-plugin-ip-lookup
/packages/medusa-plugin-mailchimp
/packages/medusa-plugin-permissions
/packages/medusa-plugin-restock-notification
/packages/medusa-plugin-segment
/packages/medusa-plugin-sendgrid
/packages/medusa-plugin-slack-notification
/packages/medusa-plugin-twilio-sms
/packages/medusa-plugin-wishlist
/packages/medusa-telemetry
/packages/medusa-test-utils
typedoc.*
jest*

packages/**/scripts
packages/*/*.js
**/dist/*
packages/*
# List of packages to Lint
!packages/medusa

integration-tests/*
#!integration-tests/api


**/models/*
**/scripts/*
**/dist/*
**/node_modules/*
**/migrations/*
**/__mocks__/*
**/__tests__/*

jest.config.js
.eslintrc.js
140 changes: 87 additions & 53 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,111 @@
module.exports = {
parser: `@babel/eslint-parser`,
root: true,
parser: "@babel/eslint-parser",
parserOptions: {
requireConfigFile: false,
ecmaFeatures: {
experimentalDecorators: true,
},
},
plugins: [`eslint-plugin-prettier`],
extends: [`eslint:recommended`, `google`, `eslint-config-prettier`],
plugins: ["prettier"],
extends: ["eslint:recommended", "google", "plugin:prettier/recommended"],
rules: {
"prettier/prettier": `error`,
curly: [2, `all`],
"new-cap": `off`,
"require-jsdoc": `off`,
semi: `off`,
"no-unused-expressions": `off`,
camelcase: `off`,
"no-invalid-this": `off`,
curly: ["error", "all"],
"new-cap": "off",
"require-jsdoc": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off",
camelcase: "off",
"no-invalid-this": "off",
"max-len": [
"error",
{
code: 80,
ignoreStrings: true,
ignoreRegExpLiterals: true,
ignoreComments: true,
ignoreTrailingComments: true,
ignoreUrls: true,
ignoreTemplateLiterals: true,
},
],
semi: ["error", "never"],
quotes: [
"error",
"double",
{
allowTemplateLiterals: true,
},
],
"comma-dangle": [
"error",
{
arrays: "always-multiline",
objects: "always-multiline",
imports: "always-multiline",
exports: "always-multiline",
functions: "never",
},
],
"object-curly-spacing": ["error", "always"],
"arrow-parens": ["error", "always"],
"linebreak-style": 0,
"no-confusing-arrow": [
"error",
{
allowParens: false,
},
],
"space-before-function-paren": [
"error",
{
anonymous: "always",
named: "never",
asyncArrow: "always",
},
],
"space-infix-ops": "error",
"eol-last": ["error", "always"],
},
env: {
es6: true,
node: true,
jest: true,
},
ignorePatterns: [`**/models`, `**/repositories`],
ignorePatterns: [],
overrides: [
{
files: [`*.ts`],
parser: `@typescript-eslint/parser`,
plugins: [`@typescript-eslint/eslint-plugin`],
extends: [`plugin:@typescript-eslint/recommended`, "prettier"],
files: ["*.ts"],
plugins: ["@typescript-eslint/eslint-plugin"],
extends: ["plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./packages/medusa/tsconfig.json",
},
rules: {
"valid-jsdoc": [
"valid-jsdoc": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/keyword-spacing": "error",
"@typescript-eslint/space-before-function-paren": [
"error",
{
requireParamType: false,
requireReturnType: false,
prefer: {
arg: "param",
argument: "param",
class: "constructor",
return: "return",
virtual: "abstract",
},
anonymous: "always",
named: "never",
asyncArrow: "always",
},
],
"@typescript-eslint/explicit-function-return-type": ["error"],
"@typescript-eslint/no-non-null-assertion": ["off"],
},
},
{
files: [
"**/api/**/*.js",
"**/api/**/*.ts",
"**/medusa-js/**/resources/**/*.ts",
],
rules: {
"valid-jsdoc": ["off"],
},
},
{
// Medusa JS client
files: ["**/medusa-js/**/resources/**/*.ts"],
rules: {
"valid-jsdoc": ["off"],
},
},
{
files: ["**/api/**/*.ts"],
rules: {
"valid-jsdoc": ["off"],
"@typescript-eslint/explicit-function-return-type": ["off"],
"@typescript-eslint/no-var-requires": ["off"],
"@typescript-eslint/space-infix-ops": "error",

// --- Rules to be fixed
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-var-requires": "off",
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"devDependencies": {
"@types/node": "^16.11.10",
"typedoc": "^0.22.10",
"@typescript-eslint/eslint-plugin": "5.6.0",
"@typescript-eslint/parser": "5.6.0",
"typescript": "4.5.2"
},
"keywords": [
Expand Down
Loading

0 comments on commit a94d981

Please sign in to comment.