diff --git a/.eslintrc.json b/.eslintrc.json index 424a375..427aaa0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["airbnb", "eslint:recommended"], + "extends": ["airbnb", "prettier", "eslint:recommended"], "settings": { "import/resolver": { "node": { @@ -14,8 +14,9 @@ "node": true, "mocha": true }, - "plugins": ["simple-import-sort", "jsdoc"], + "plugins": ["prettier", "simple-import-sort", "jsdoc"], "rules": { + "prettier/prettier": "error", "comma-dangle": ["error", "always-multiline"], "object-curly-spacing": "error", "no-trailing-spaces": "error", diff --git a/README.md b/README.md index d7813eb..8c06de1 100644 --- a/README.md +++ b/README.md @@ -7,32 +7,45 @@ 1. Install config with eslint and eslint plugins -``` -npm install --save-dev \ - @exabyte-io/eslint-config \ - @babel/eslint-parser@7.16.3 \ - @babel/plugin-proposal-class-properties@7.16.0 \ - @babel/preset-env@7.16.4 \ - @babel/preset-react@7.16.7 \ - @babel/register@^7.16.0 \ - @babel/runtime-corejs3@7.16.8 \ - eslint@7.32.0 \ - eslint-config-airbnb@19.0.2 \ - eslint-import-resolver-exports@^1.0.0-beta.2 \ - eslint-import-resolver-meteor@^0.4.0 \ - eslint-import-resolver-node@^0.3.6 \ - eslint-plugin-import@2.25.3 \ - eslint-plugin-jsdoc@37.1.0 \ - eslint-plugin-jsx-a11y@6.5.1 \ - eslint-plugin-react@7.30.0 \ - eslint-plugin-simple-import-sort@7.0.0 -``` + ``` + npm install --save-dev \ + @exabyte-io/eslint-config \ + @babel/eslint-parser@7.16.3 \ + @babel/plugin-proposal-class-properties@7.16.0 \ + @babel/preset-env@7.16.4 \ + @babel/preset-react@7.16.7 \ + @babel/register@^7.16.0 \ + @babel/runtime-corejs3@7.16.8 \ + eslint@7.32.0 \ + eslint-config-airbnb@19.0.2 \ + eslint-config-prettier@8.5.0 \ + eslint-import-resolver-exports@^1.0.0-beta.2 \ + eslint-import-resolver-meteor@^0.4.0 \ + eslint-import-resolver-node@^0.3.6 \ + eslint-plugin-import@2.25.3 \ + eslint-plugin-jsdoc@37.1.0 \ + eslint-plugin-jsx-a11y@6.5.1 \ + eslint-plugin-prettier@4.2.1 \ + eslint-plugin-react@7.30.0 \ + eslint-plugin-simple-import-sort@7.0.0 + ``` 2. Create own `.eslintrc.json`: -``` -{ - "extends": "@exabyte-io/eslint-config" -} -``` + ```JSON + { + "extends": "@exabyte-io/eslint-config" + } + ``` + +3. Add prettier config `.prettierrc`: + + ```JSON + { + "singleQuote": false, + "printWidth": 100, + "trailingComma": "all", + "tabWidth": 4 + } + ``` diff --git a/index.js b/index.js index f0d35be..1a70447 100644 --- a/index.js +++ b/index.js @@ -1,80 +1,59 @@ module.exports = { - extends: ['airbnb', 'eslint:recommended'], - settings: { - 'import/resolver': { - node: { - paths: ['src'], - }, - exports: {}, + extends: ["airbnb", "prettier", "eslint:recommended"], + settings: { + "import/resolver": { + node: { + paths: ["src"], + }, + exports: {}, + }, }, - }, - parser: '@babel/eslint-parser', - env: { - browser: true, - node: true, - mocha: true, - }, - plugins: ['simple-import-sort', 'jsdoc'], - rules: { - 'array-element-newline': ['error', 'consistent'], - 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], - 'object-curly-spacing': 'error', - 'no-trailing-spaces': 'error', - 'one-var': ['error', { uninitialized: 'always', initialized: 'never' }], - 'brace-style': ['error', '1tbs', { allowSingleLine: true }], - 'prefer-template': 'off', - camelcase: 'off', - 'no-console': 'off', - 'no-unused-expressions': 'warn', - 'no-confusing-arrow': 'off', - 'no-underscore-dangle': 'off', - 'no-return-assign': 'off', - 'consistent-return': 'off', - 'arrow-body-style': 'off', - 'import/prefer-default-export': 'off', - 'import/no-named-as-default-member': 'warn', - 'no-param-reassign': ['warn', { props: false }], - 'max-classes-per-file': 'warn', - 'simple-import-sort/imports': [ - 'warn', - { - groups: [ - // Side effect imports. - ['^\\u0000'], - // Packages. - // Things that start with a letter (or digit or underscore), or `@` followed by a letter. - ['^@?\\w'], - // Absolute imports - [ - '^(components|configs|constants|containers|domain|enhancers|hocs|libs|pages|reducers|services|store|modules|dictionaries)(/.*|$)', - ], - // Relative imports. - // Anything that starts with a dot. - ['^\\.'], + parser: "@babel/eslint-parser", + env: { + browser: true, + node: true, + mocha: true, + }, + plugins: ["simple-import-sort", "prettier", "jsdoc"], + rules: { + "prettier/prettier": "error", + "array-element-newline": ["error", "consistent"], + "no-plusplus": ["error", { allowForLoopAfterthoughts: true }], + "object-curly-spacing": "error", + "no-trailing-spaces": "error", + "one-var": ["error", { uninitialized: "always", initialized: "never" }], + "brace-style": ["error", "1tbs", { allowSingleLine: true }], + "prefer-template": "off", + camelcase: "off", + "no-console": "off", + "no-unused-expressions": "warn", + "no-confusing-arrow": "off", + "no-underscore-dangle": "off", + "no-return-assign": "off", + "consistent-return": "off", + "arrow-body-style": "off", + "import/prefer-default-export": "off", + "import/no-named-as-default-member": "warn", + "no-param-reassign": ["warn", { props: false }], + "max-classes-per-file": "warn", + "simple-import-sort/imports": [ + "warn", + { + groups: [ + // Side effect imports. + ["^\\u0000"], + // Packages. + // Things that start with a letter (or digit or underscore), or `@` followed by a letter. + ["^@?\\w"], + // Absolute imports + [ + "^(components|configs|constants|containers|domain|enhancers|hocs|libs|pages|reducers|services|store|modules|dictionaries)(/.*|$)", + ], + // Relative imports. + // Anything that starts with a dot. + ["^\\."], + ], + }, ], - }, - ], - indent: [ - 'error', - 4, - { - SwitchCase: 1, - ignoredNodes: ['TemplateLiteral'], - }, - ], - 'comma-dangle': ['error', 'always-multiline'], - quotes: [1, 'double', 'avoid-escape'], - 'jsx-quotes': ['error', 'prefer-double'], - 'max-len': [ - 'error', - 100, - 4, - { - ignoreUrls: true, - ignoreComments: true, - ignoreTemplateLiterals: true, - ignoreStrings: true, - }, - ], - }, + }, }; diff --git a/package-lock.json b/package-lock.json index bc76136..8b4705f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@exabyte-io/eslint-config-mat3ra", - "version": "0.0.0", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2398,6 +2398,12 @@ "semver": "^6.3.0" } }, + "eslint-config-prettier": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", + "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", + "dev": true + }, "eslint-import-resolver-exports": { "version": "1.0.0-beta.3", "resolved": "https://registry.npmjs.org/eslint-import-resolver-exports/-/eslint-import-resolver-exports-1.0.0-beta.3.tgz", @@ -2573,6 +2579,15 @@ } } }, + "eslint-plugin-prettier": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz", + "integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, "eslint-plugin-react": { "version": "7.30.0", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.30.0.tgz", @@ -2765,6 +2780,12 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -4406,6 +4427,15 @@ "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", "dev": true }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "process-on-spawn": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", diff --git a/package.json b/package.json index 4431a49..ddb3be2 100644 --- a/package.json +++ b/package.json @@ -16,14 +16,15 @@ "main": "index.js", "files": [ "index.js", - ".babelrc" + ".babelrc", + ".prettierrc" ], "author": "Exabyte Inc.", "bugs": { - "url": "https://github.com/Exabyte-io/eslint-config-mat3ra/issues" + "url": "https://github.com/Exabyte-io/eslint-config/issues" }, "license": "Apache-2.0", - "homepage": "https://github.com/Exabyte-io/eslint-config-mat3ra", + "homepage": "https://github.com/Exabyte-io/eslint-config", "devDependencies": { "@babel/eslint-parser": "7.16.3", "@babel/plugin-proposal-class-properties": "7.16.0", @@ -33,12 +34,14 @@ "@babel/runtime-corejs3": "7.16.8", "eslint": "7.32.0", "eslint-config-airbnb": "19.0.2", + "eslint-config-prettier": "^8.5.0", "eslint-import-resolver-exports": "^1.0.0-beta.2", "eslint-import-resolver-meteor": "^0.4.0", "eslint-import-resolver-node": "^0.3.6", "eslint-plugin-import": "2.25.3", "eslint-plugin-jsdoc": "37.1.0", "eslint-plugin-jsx-a11y": "6.5.1", + "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "7.30.0", "eslint-plugin-simple-import-sort": "7.0.0", "husky": "^7.0.4", @@ -56,12 +59,14 @@ "@babel/runtime-corejs3": "7.16.8", "eslint": "7.32.0", "eslint-config-airbnb": "19.0.2", + "eslint-config-prettier": "^8.5.0", "eslint-import-resolver-exports": "^1.0.0-beta.2", "eslint-import-resolver-meteor": "^0.4.0", "eslint-import-resolver-node": "^0.3.6", "eslint-plugin-import": "2.25.3", "eslint-plugin-jsdoc": "37.1.0", "eslint-plugin-jsx-a11y": "6.5.1", + "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-react": "7.30.0", "eslint-plugin-simple-import-sort": "7.0.0" },