├── .circleci └── config.yml ├── .dependabot └── config.yml ├── .eslintrc.js ├── .github └── CODEOWNERS ├── .gitignore ├── .nvmrc ├── .prettierignore ├── README.md ├── commitlint.config.js ├── lerna.json ├── package.json ├── packages ├── eslint-config-datacamp │ ├── CHANGELOG.md │ ├── helpers.js │ ├── index.js │ ├── package.json │ ├── typescript-with-type-information.js │ └── typescript.js └── prettier-config-datacamp │ ├── CHANGELOG.md │ ├── index.js │ └── package.json ├── prettier.config.js └── yarn.lock /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | $schema: https://json.schemastore.org/circleciconfig# 2 | version: 2.1 3 | executors: 4 | node: 5 | docker: 6 | - image: cimg/node:18.20.6 7 | jobs: 8 | checks: 9 | executor: node 10 | steps: 11 | - checkout 12 | - run: 13 | name: Add .npmrc 14 | command: printf "@datacamp:registry=https://registry.npmjs.org/\n//registry.npmjs.org/:_authToken=$NPM_TOKEN\n" > .npmrc 15 | - run: 16 | name: Install dependencies 17 | command: yarn install 18 | - run: 19 | name: Check commitlint 20 | command: yarn commitlint:ci 21 | - run: 22 | name: Lint 23 | command: yarn lint 24 | workflows: 25 | pr_flow: 26 | jobs: 27 | - checks: 28 | context: org-global 29 | filters: 30 | branches: 31 | ignore: 32 | - main 33 | -------------------------------------------------------------------------------- /.dependabot/config.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | update_configs: 3 | - package_manager: 'javascript' 4 | directory: '/' 5 | update_schedule: 'weekly' 6 | version_requirement_updates: 'increase_versions' 7 | automerged_updates: 8 | - match: 9 | dependency_type: 'all' 10 | update_type: 'semver:minor' 11 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@datacamp/eslint-config'], 3 | }; 4 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @datacamp-engineering/tf-jsconfig 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 18.20.6 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | CHANGELOG.md 2 | package.json 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JSConfig 2 | 3 | This repo provides a set of npm packages that configure the awesome tooling we use every day. There are a lot of these standards out there, but as a company we have specific needs, so this is here to serve us in the best way. 4 | 5 | Also, when you have too many standards, xkcd recommends to create a new standard ([Source](https://xkcd.com/927/)). 6 | 7 | ## Vision 8 | 9 | By having a vision, we can make some decisions more easily by refering back to this vision and how a change contributes to this vision. 10 | 11 | The goal of JS Config is to improve the productivity of our developers (in the long term). This means we should strive for (in order of importance): 12 | 13 | 1. _Consistency_: auto-formatting / auto-sorting stuff: Developers should not need to think about this stuff and still find their code in a readable and consistent order / syntax. There shouldn't be a lot of discussion about which style to pick as it's just a matter of taste and getting used too. Let's try to stay as close as possible to "community standards". 14 | 1. _Correctness_: small bugs (e.g. eslint rules about hooks) should be catched by eslint not by (human) reviews. Rules that catch potential bugs and with few false positives should be enabled. 15 | 1. _Code Quality_: Rules that help in code quality and are not flagging too many false positives could be enabled as well. 16 | 1. _Unity_: Having as many configs as possible in this repo and use it in as many projects as possible with at little adaptation as possible (but adaptation is still allowed!). That way engineers can assume a good and working setup and don’t need to catch little bugs during review time if a linter can do this. 17 | 18 | ## Installation :floppy_disk: 19 | 20 | (If you are using npm, you should use `npm install` instead of `yarn add`) 21 | 22 | ### ESlint :wrench: 23 | 24 | ```bash 25 | yarn add -D eslint @datacamp/eslint-config 26 | ``` 27 | 28 | Create a file `.eslintrc.js` with the following contents 29 | 30 | ```js 31 | // .eslintrc.js 32 | module.exports = { 33 | extends: ['@datacamp/eslint-config'], 34 | }; 35 | ``` 36 | 37 | For typescript projects you can use the following config: 38 | 39 | ```js 40 | // .eslintrc.js 41 | module.exports = { 42 | extends: ['@datacamp/eslint-config/typescript'], 43 | }; 44 | ``` 45 | 46 | Or even better if you also want to enable a bunch of rules for which type-information is needed 47 | 48 | ```js 49 | // .eslintrc.js 50 | const path = require('path'); 51 | 52 | module.exports = { 53 | extends: ['@datacamp/eslint-config/typescript-with-type-information'], 54 | parserOptions: { 55 | project: path.join(__dirname, './tsconfig.eslint.json'), 56 | tsconfigRootDir: __dirname, 57 | } 58 | }; 59 | 60 | // tsconfig.eslint.json 61 | { 62 | "exclude": ["node_modules", "**/node_modules", "**/dist"], 63 | "extends": "./tsconfig.json", // Make sure to let this point to your local tsconfig.json 64 | "include": ["**/*", ".eslintrc.js"] 65 | } 66 | ``` 67 | 68 | Feel free to configure the `parserOptions` differently. But this setup should hopefully work for most repositories. There is more documentation available ([[1](https://typescript-eslint.io/linting/typed-linting/)], [[2](https://typescript-eslint.io/linting/typed-linting/monorepos)] & [[3](https://typescript-eslint.io/architecture/parser/#project)]) 69 | 70 | For front-end projects, you might want to adjust the environment: 71 | 72 | ```js 73 | // .eslintrc.js 74 | module.exports = { 75 | // [...] 76 | env: { 77 | browser: true, 78 | }, 79 | }; 80 | ``` 81 | 82 | Afterwards you can run eslint as follows: 83 | 84 | ```bash 85 | yarn eslint . --ext ts,tsx,js,json --ignore-path .gitignore 86 | ``` 87 | 88 | It's recommended to: 89 | 90 | - also install our common prettier config (as ESlint config uses your prettier config to lint for code style) 91 | - install an eslint plugin for your editor of choice (to see errors / warnings in your editor) 92 | 93 | ### Prettier :nail_care: 94 | 95 | ```bash 96 | yarn add -D prettier @datacamp/prettier-config 97 | ``` 98 | 99 | Create a file `prettier.config.js` with the following contents 100 | 101 | ```js 102 | // prettier.config.js 103 | module.exports = { 104 | ...require('@datacamp/prettier-config'), 105 | }; 106 | ``` 107 | 108 | It's recommended to: 109 | 110 | - also install eslint to check whether your files are following your prettier config. 111 | - install prettier plugin for your editor of choice 112 | 113 | ### NestJS :lion: 114 | 115 | For DI to properly consume Reflect metadata add to your `.eslintrc.js` file: 116 | ``` 117 | parserOptions: { 118 | emitDecoratorMetadata: true, 119 | } 120 | ``` 121 | 122 | It causes TypeScript to create references to value imports when they are used in a type-only location. 123 | 124 | More context [here](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-type-imports.md#usage-with-emitdecoratormetadata) 125 | 126 | ## Contribute :family: 127 | 128 | ### Developer guide 129 | 130 | All the configs are in the `packages/` directory. We use [lerna](https://github.com/lerna/lerna) to manage dependencies. 131 | 132 | Install the dependencies for all the subpackages using `yarn` in the root of the project. 133 | 134 | If you need help, ping the #javascript channel on Slack. 135 | 136 | ### Decisions process :hocho: 137 | 138 | 1. Try out the configuration in your own project for a while (so the cost / benefit trade-off becomes more apparent) 139 | 1. Create a PR (or an issue with a proposal if the PR would be a lot of work) outlying the changes + why it's a good idea. You can refer to the vision on what level it improves developer productivity (Consistency, Correctness, Code Quality, Unity). 140 | 1. Communicate proposal in #javascript channel on Slack 141 | 1. On the next javascript guild meeting, we go over all open PRs and quickly discuss as a group on whether we think it's a good idea. For this, we base ourselves on the vision. A change that fits the vision well has a higher chance of getting merged. 142 | 143 | ### Commit messages 144 | 145 | We use [commitlint]() to lint our commit messages and follow [config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#type-enum). The version of the packages will be bumped based on the commit messages as well, see [the conventional commits website](https://www.conventionalcommits.org/en/v1.0.0/) for more information (short version: fix=patch, feat=minor, BREAKING CHANGE footer=major) 146 | 147 | It's hard to know what is a breaking change so these our the guidelines: 148 | 149 | - It's a breaking change if it adds new errors that are not auto-fixable. So after running eslint --fix you should be good again and you just need to review the things it fixed 150 | - It's a breaking change if it expects to change a lot of code on --fix E.g. object literal properties should be ordered (it's auto fixable but it's gonna mess up a lot of code). Most prettier changes will also fall under this 151 | 152 | So in short, users should be able to run `eslint --fix` (or equivalent) and review a few things but it should be doable to review in <10 minutes, even for large projects. 153 | Other changes could qualify as well but then we basically always have major changes and almost never minor so that's why we choose these guidelines (for now). We're open to change them if they don't work for us. 154 | 155 | ### Publishing 156 | 157 | You can publish all the packages you've edited. This will run `lerna publish` under the hood: 158 | 159 | ```bash 160 | yarn release 161 | ``` 162 | 163 | This will propose version numbers for you and push a commit with a changelog to all the individual packages. 164 | 165 | _Please only run this from main and make sure to pull the latest main before you run it._ Running it will push a commit to main which the updated changelog etc. 166 | 167 | ## Example Projects using JSConfig 168 | 169 | - [DataCamp's Design System](https://github.com/datacamp/design-system) 170 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | rules: { 4 | 'body-max-line-length': [2, 'always', Infinity], 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "command": { 3 | "publish": { 4 | "allowBranch": "main", 5 | "message": "chore: publish packages" 6 | } 7 | }, 8 | "version": "independent", 9 | "npmClient": "yarn", 10 | "useWorkspaces": true, 11 | "packages": ["packages/*"] 12 | } 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "devDependencies": { 4 | "@commitlint/config-conventional": "^17.4.3", 5 | "commitlint": "^17.4.3", 6 | "eslint": "^8.0.0", 7 | "husky": "^4.3.8", 8 | "lerna": "^8.1.9", 9 | "prettier": "2.8.4" 10 | }, 11 | "scripts": { 12 | "lint": "eslint .", 13 | "release": "lerna publish --conventional-commits", 14 | "commitlint:ci": "commitlint --config commitlint.config.js --from \"origin/main\"" 15 | }, 16 | "husky": { 17 | "hooks": { 18 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js" 19 | } 20 | }, 21 | "workspaces": [ 22 | "packages/*" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /packages/eslint-config-datacamp/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [7.1.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@7.0.0...@datacamp/eslint-config@7.1.0) (2023-03-16) 7 | 8 | 9 | ### Features 10 | 11 | * e2e-spec files as test files ([c8e1023](https://github.com/datacamp-engineering/jsconfig/commit/c8e10232af2409109ee8804b130c268e8da203c2)) 12 | 13 | 14 | 15 | 16 | 17 | # [6.1.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@6.0.0...@datacamp/eslint-config@6.1.0) (2023-02-27) 18 | 19 | ### Features 20 | 21 | - **eslint-config-datacamp:** add recommended-requiring-type-checking ([d84268b](https://github.com/datacamp-engineering/jsconfig/commit/d84268b45d421e7cc6b32b693f04a61c4abac33f)) 22 | - **eslint-config-datacamp:** add typescript-with-type-information boilerplate ([23a85e8](https://github.com/datacamp-engineering/jsconfig/commit/23a85e8b4c7a8e7a1c48437168a2d39dac5d5c1b)) 23 | - **eslint-config-datacamp:** port over some changes by collab-and-tooling squad ([e3ff8de](https://github.com/datacamp-engineering/jsconfig/commit/e3ff8def6c4fe2020162b4e13d79d13e23bd7a07)) 24 | 25 | # [6.0.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@5.0.0...@datacamp/eslint-config@6.0.0) (2021-08-04) 26 | 27 | ### chore 28 | 29 | - bump ESLint to v7.0.0 ([18fee7f](https://github.com/datacamp-engineering/jsconfig/commit/18fee7feb4db9f62aea32eb642aa392925b6f6ea)) 30 | 31 | ### BREAKING CHANGES 32 | 33 | - new rules will require manual changes to fix 34 | 35 | # [5.0.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@4.1.0...@datacamp/eslint-config@5.0.0) (2021-02-08) 36 | 37 | ### Bug Fixes 38 | 39 | - use @typrscript-eslint/no-use-before-define instead of default ([8adf7a4](https://github.com/datacamp-engineering/jsconfig/commit/8adf7a4f66fe3c854d261ea7371033ebacecf9a3)) 40 | 41 | ### Features 42 | 43 | - allow config files to contain dev dependencies ([d3adbe2](https://github.com/datacamp-engineering/jsconfig/commit/d3adbe24ff33fd22325c42a6ff558ad03269f575)) 44 | - only allow //ts-expect-error and require a description why added ([f8bc416](https://github.com/datacamp-engineering/jsconfig/commit/f8bc416e0dad7b45f4a27cf3d59457203715daf9)) 45 | - turn off @typescript-eslint/no-empty-function in tests ([98464f0](https://github.com/datacamp-engineering/jsconfig/commit/98464f020fd1a2fd2e81e8a3c4651f9264285102)) 46 | - turn off class-methods-use-this ([3d7fb98](https://github.com/datacamp-engineering/jsconfig/commit/3d7fb98832e9a8e81ea805f778f29cbf9e64edd4)) 47 | - turn off import/prefer-default-export ([42ba9f7](https://github.com/datacamp-engineering/jsconfig/commit/42ba9f7ef22a1f37f0f879ebd44ade3fa6c5cd0d)) 48 | - turn off max-classes-per-file ([a8fe9c6](https://github.com/datacamp-engineering/jsconfig/commit/a8fe9c69a148ce862eb27c935a73df2bb8b7cc98)) 49 | - turn off no-useless-constructor ([e76c53b](https://github.com/datacamp-engineering/jsconfig/commit/e76c53b225bc91fd7a4bec57c65c1d006fc401a5)) 50 | - turn off sonarjs/no-duplicate-string ([a9b4e73](https://github.com/datacamp-engineering/jsconfig/commit/a9b4e7333fd6a6cdd7e7f908312a98b7eee59fc9)) 51 | - turn off sonarjs/prefer-immediate-return ([dba6036](https://github.com/datacamp-engineering/jsconfig/commit/dba6036ffd81dfccef482dcf387774739136e3e2)) 52 | 53 | ### BREAKING CHANGES 54 | 55 | - add @typescript-eslint/no-unused-vars except if start with \_ ([68c3dee](https://github.com/datacamp-engineering/jsconfig/commit/68c3dee5db4585cde9689706515377d897977562)) 56 | - forbid naming interfaces starting with a capital I ([5fd6349](https://github.com/datacamp-engineering/jsconfig/commit/5fd6349f3e2afbc7f600f8a07fc4c5dde70d01c7)) 57 | - add prefer-type-alias/prefer-type-alias ([fd2bff1](https://github.com/datacamp-engineering/jsconfig/commit/fd2bff196c836807e7ffd3179e2ce96c834e1a17)) 58 | 59 | # [4.1.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@4.0.0...@datacamp/eslint-config@4.1.0) (2020-09-18) 60 | 61 | ### Features 62 | 63 | - **eslint:** sort destructuring keys ([861a5b4](https://github.com/datacamp-engineering/jsconfig/commit/861a5b4)) 64 | 65 | # [4.0.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@3.1.1...@datacamp/eslint-config@4.0.0) (2020-08-27) 66 | 67 | ### Features 68 | 69 | - **eslint:** no anonymous default Export ([66fb4ae](https://github.com/datacamp-engineering/jsconfig/commit/66fb4ae)) 70 | 71 | ### BREAKING CHANGES 72 | 73 | - **eslint:** no anonymous default export 74 | 75 | ## [3.1.1](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@3.1.0...@datacamp/eslint-config@3.1.1) (2020-08-18) 76 | 77 | ### Bug Fixes 78 | 79 | - **eslint:** fix array-type config ([e14c376](https://github.com/datacamp-engineering/jsconfig/commit/e14c376)) 80 | 81 | # [3.1.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@3.0.0...@datacamp/eslint-config@3.1.0) (2020-08-13) 82 | 83 | ### Features 84 | 85 | - **eslint:** add array-type rule ([4bdac88](https://github.com/datacamp-engineering/jsconfig/commit/4bdac88)) 86 | 87 | # [3.0.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@2.0.0...@datacamp/eslint-config@3.0.0) (2020-08-06) 88 | 89 | ### Features 90 | 91 | - add sonar-lint ([23b18ec](https://github.com/datacamp-engineering/jsconfig/commit/23b18ec)) 92 | 93 | ### BREAKING CHANGES 94 | 95 | - Add sonar-lint rules and not all of them are autofixable 96 | 97 | # [2.0.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@1.3.0...@datacamp/eslint-config@2.0.0) (2020-08-03) 98 | 99 | ### Features 100 | 101 | - add eslint-plugin-comments ([704bd0d](https://github.com/datacamp-engineering/jsconfig/commit/704bd0d)) 102 | 103 | ### BREAKING CHANGES 104 | 105 | - there is no autofix for this rule, so it requires manual intervention 106 | 107 | # [1.3.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@1.2.0...@datacamp/eslint-config@1.3.0) (2020-07-30) 108 | 109 | ### Features 110 | 111 | - adds repository info to package.json files ([5a28357](https://github.com/datacamp-engineering/jsconfig/commit/5a28357)) 112 | 113 | # [1.2.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@1.1.0...@datacamp/eslint-config@1.2.0) (2020-07-29) 114 | 115 | ### Bug Fixes 116 | 117 | - set no-explicit-any to off for test files ([9278582](https://github.com/datacamp-engineering/jsconfig/commit/9278582)) 118 | 119 | ### Features 120 | 121 | - **eslintrc:** allow ts-ignore in tests ([da5a15a](https://github.com/datacamp-engineering/jsconfig/commit/da5a15a)) 122 | 123 | # [1.1.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@1.0.1...@datacamp/eslint-config@1.1.0) (2020-04-01) 124 | 125 | ### Features 126 | 127 | - allow typescript imports without extensions ([c6e3444](https://github.com/datacamp-engineering/jsconfig/commit/c6e3444)) 128 | - don't require return types in js files ([bd6887a](https://github.com/datacamp-engineering/jsconfig/commit/bd6887a)) 129 | 130 | ## [1.0.1](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@1.0.0...@datacamp/eslint-config@1.0.1) (2020-02-14) 131 | 132 | ### Bug Fixes 133 | 134 | - fix typo ([747c120](https://github.com/datacamp-engineering/jsconfig/commit/747c120)) 135 | 136 | # [1.0.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/eslint-config@0.1.0...@datacamp/eslint-config@1.0.0) (2020-02-14) 137 | 138 | ### Features 139 | 140 | - sort properties case insensitive ([#73](https://github.com/datacamp-engineering/jsconfig/issues/73)) ([6bb707f](https://github.com/datacamp-engineering/jsconfig/commit/6bb707f)) 141 | 142 | ### BREAKING CHANGES 143 | 144 | - Sorting of keys and enums is no longer case sensitive. 145 | 146 | # 0.1.0 (2020-02-13) 147 | 148 | ### Bug Fixes 149 | 150 | - Add homepage to package.json ([#51](https://github.com/datacamp-engineering/jsconfig/issues/51)) ([04fd7fd](https://github.com/datacamp-engineering/jsconfig/commit/04fd7fd)) 151 | 152 | ### Features 153 | 154 | - Sort imports ([#19](https://github.com/datacamp-engineering/jsconfig/issues/19)) ([a02bbc4](https://github.com/datacamp-engineering/jsconfig/commit/a02bbc4)) 155 | -------------------------------------------------------------------------------- /packages/eslint-config-datacamp/helpers.js: -------------------------------------------------------------------------------- 1 | exports.testFilesGlobPatterns = [ 2 | '**/*.{spec,e2e-spec,test,e2e-test}.{js,jsx,ts,tsx}', 3 | '**/__mocks__/**', 4 | '**/{test,tests,spec,specs,__mocks__}/**', 5 | '**/{cypress}/**', 6 | ]; 7 | -------------------------------------------------------------------------------- /packages/eslint-config-datacamp/index.js: -------------------------------------------------------------------------------- 1 | const { testFilesGlobPatterns } = require('./helpers'); 2 | 3 | // Ignored rules deprecated in v7.0.0 of ESLint but present in eslint-node-plugin 4 | // https://eslint.org/blog/2020/02/whats-coming-in-eslint-7.0.0#deprecating-nodejscommonjs-specific-rules 5 | // 'callback-return', 'global-require', 'handle-callback-err', 'no-mixed-requires', 'no-new-require', 'no-path-concat', 'no-process-env', 'no-process-exit' 6 | // Possible errors have been set to 'error' and Stylistic issues have been set to 'off' 7 | 8 | module.exports = { 9 | extends: [ 10 | 'eslint:recommended', 11 | 'airbnb-base', 12 | 'plugin:json/recommended', 13 | 'plugin:jest/recommended', 14 | 'plugin:prettier/recommended', 15 | 'prettier', 16 | 'prettier/prettier', 17 | 'plugin:sonarjs/recommended', 18 | 'plugin:node/recommended', 19 | ], 20 | overrides: [ 21 | { 22 | env: { 23 | jest: true, 24 | }, 25 | files: testFilesGlobPatterns, 26 | rules: { 27 | 'sonarjs/no-identical-functions': 'off', 28 | }, 29 | }, 30 | { 31 | files: ['prettier.config.js'], 32 | rules: { 33 | 'import/no-extraneous-dependencies': 'off', 34 | 'node/global-require': 'off', 35 | }, 36 | }, 37 | ], 38 | parser: '@babel/eslint-parser', 39 | parserOptions: { 40 | ecmaVersion: 2019, 41 | requireConfigFile: false, 42 | sourceType: 'module', 43 | }, 44 | plugins: [ 45 | 'eslint-comments', 46 | 'filenames', 47 | 'json', 48 | 'react', 49 | 'react-hooks', 50 | 'simple-import-sort', 51 | 'sonarjs', 52 | 'sort-destructure-keys', 53 | 'sort-keys-fix', 54 | '@datacamp/waffles', 55 | '@datacamp/workspace', 56 | ], 57 | rules: { 58 | '@datacamp/waffles/tokens': 'error', 59 | '@datacamp/workspace/track-clicks': 'error', 60 | 'class-methods-use-this': 'off', 61 | 'comma-dangle': 'off', // Defined by prettier 62 | curly: ['error', 'all'], 63 | 'default-param-last': 'off', // doesn't work well with reducers 64 | eqeqeq: ['error', 'always', { null: 'never' }], 65 | 'eslint-comments/no-unused-disable': 'error', 66 | 'eslint-comments/no-unused-enable': 'error', 67 | 'filenames/match-exported': ['error', [null, 'camel', 'kebab'], null, true], 68 | 'global-require': 'off', // Deprecated in ESLint 7.0.0, uses node/global-require instead 69 | 'handle-callback-err': 'off', // Deprecated in ESLint 7.0.0, uses node/handle-callback-err instead 70 | 'import/no-anonymous-default-export': ['error', { allowObject: true }], 71 | 'import/no-deprecated': 'warn', 72 | 'import/no-extraneous-dependencies': [ 73 | 'error', 74 | { 75 | devDependencies: [ 76 | ...testFilesGlobPatterns, 77 | '.storybook/**.js', 78 | '**/*.stories.js', 79 | '**/catalog.config.js', 80 | '**/webpack.config.js', 81 | '**/gulpfile.js', 82 | '**/prettier.config.js', 83 | '**/jest.config.js', 84 | '**/babel.config.js', 85 | '**/.eslintrc.js', 86 | ], 87 | }, 88 | ], 89 | 'import/prefer-default-export': 'off', 90 | 'jest/no-deprecated-functions': 'off', // Needs to know the jest version, not possible from a shared config 91 | 'jest/no-disabled-tests': 'error', 92 | 'max-classes-per-file': 'off', 93 | 'no-console': 'error', 94 | 'no-mixed-requires': 'off', // Deprecated in ESLint 7.0.0, uses node/no-mixed-requires instead 95 | 'no-new-require': 'off', // Deprecated in ESLint 7.0.0, uses node/no-new-require instead 96 | 'no-path-concat': 'off', // Deprecated in ESLint 7.0.0, uses node/no-path-concat instead 97 | 'no-plusplus': 'off', 98 | 'no-process-env': 'off', // Deprecated in ESLint 7.0.0, uses node/no-process-env instead 99 | 'no-process-exit': 'off', // Deprecated in ESLint 7.0.0, uses node/no-process-exit instead 100 | 'no-useless-catch': 'error', 101 | 'no-useless-constructor': 'off', 102 | 'no-void': ['error', { allowAsStatement: true }], 103 | 'node/callback-return': 'off', 104 | 'node/global-require': 'off', 105 | 'node/handle-callback-err': 'error', 106 | 'node/no-missing-import': 'off', 107 | 'node/no-mixed-requires': 'off', 108 | 'node/no-new-require': 'error', 109 | 'node/no-path-concat': 'error', 110 | 'node/no-process-env': 'off', 111 | 'node/no-process-exit': 'error', 112 | 'node/no-unpublished-import': 'off', 113 | 'node/no-unpublished-require': 'off', 114 | 'node/no-unsupported-features/es-builtins': 'off', 115 | 'node/no-unsupported-features/es-syntax': 'off', 116 | 'node/no-unsupported-features/node-builtins': 'off', 117 | 'object-shorthand': ['error', 'always'], 118 | 'prefer-const': 'error', 119 | 'prefer-template': 'error', 120 | 'prettier/prettier': 'error', 121 | 'react/jsx-boolean-value': 'error', 122 | 'react/jsx-sort-props': 'error', 123 | 'react/jsx-uses-react': 'error', 124 | 'react/jsx-uses-vars': 'error', 125 | 'react/self-closing-comp': 'error', 126 | 'react-hooks/exhaustive-deps': 'error', 127 | 'react-hooks/rules-of-hooks': 'error', 128 | 'simple-import-sort/imports': [ 129 | 'error', 130 | { 131 | groups: [ 132 | // Side effect imports. 133 | ['^\\u0000'], 134 | // NodeJS modules 135 | [`^(${require('module').builtinModules.join('|')})(/|$)`], 136 | // Packages 137 | ['^@?\\w'], 138 | // Absolute imports 139 | ['^(src|app)/'], 140 | // Relative imports (outside local folder) 141 | ['^\\.{2}/'], 142 | // Relative imports (inside local folder) 143 | ['^\\.{1}/'], 144 | ], 145 | }, 146 | ], 147 | 'sonarjs/cognitive-complexity': 'warn', 148 | 'sonarjs/max-switch-cases': 'off', 149 | 'sonarjs/no-duplicate-string': 'off', 150 | 'sonarjs/no-nested-switch': 'off', 151 | 'sonarjs/no-nested-template-literals': 'off', 152 | 'sonarjs/no-small-switch': 'off', 153 | 'sonarjs/prefer-immediate-return': 'off', 154 | 'sonarjs/prefer-single-boolean-return': 'off', 155 | 'sort-destructure-keys/sort-destructure-keys': 'error', 156 | 'sort-keys-fix/sort-keys-fix': [ 157 | 'error', 158 | 'asc', 159 | { caseSensitive: false, natural: true }, 160 | ], 161 | 'sort-order': 'off', 162 | }, 163 | }; 164 | -------------------------------------------------------------------------------- /packages/eslint-config-datacamp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@datacamp/eslint-config", 3 | "version": "7.1.0", 4 | "main": "index.js", 5 | "files": [ 6 | "*.js", 7 | "CHANGELOG.md" 8 | ], 9 | "dependencies": { 10 | "@babel/core": "^7.20.12", 11 | "@babel/eslint-parser": "^7.19.1", 12 | "@datacamp/eslint-plugin-waffles": "^1.0.0", 13 | "@datacamp/eslint-plugin-workspace": "^1.0.2", 14 | "@typescript-eslint/eslint-plugin": "^5.12.1", 15 | "@typescript-eslint/parser": "^5.52.0", 16 | "eslint-config-airbnb-base": "^15.0.0", 17 | "eslint-config-prettier": "^8.6.0", 18 | "eslint-plugin-eslint-comments": "^3.2.0", 19 | "eslint-plugin-filenames": "^1.3.2", 20 | "eslint-plugin-import": "^2.27.5", 21 | "eslint-plugin-jest": "^27.2.1", 22 | "eslint-plugin-json": "^3.1.0", 23 | "eslint-plugin-node": "^11.1.0", 24 | "eslint-plugin-prefer-type-alias": "^0.1.0", 25 | "eslint-plugin-prettier": "^4.2.1", 26 | "eslint-plugin-react": "^7.32.2", 27 | "eslint-plugin-react-hooks": "^4.6.0", 28 | "eslint-plugin-simple-import-sort": "^10.0.0", 29 | "eslint-plugin-sonarjs": "^0.18.0", 30 | "eslint-plugin-sort-destructure-keys": "^1.5.0", 31 | "eslint-plugin-sort-keys-fix": "^1.1.0", 32 | "eslint-plugin-typescript-sort-keys": "^2.1.0" 33 | }, 34 | "peerDependencies": { 35 | "eslint": "^8.0.0" 36 | }, 37 | "homepage": "https://github.com/datacamp-engineering/jsconfig", 38 | "repository": { 39 | "type": "git", 40 | "url": "git+https://github.com/datacamp-engineering/jsconfig.git", 41 | "directory": "packages/eslint-config-datacamp" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/eslint-config-datacamp/typescript-with-type-information.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This config requries type information. This means that some extra setup must be done. 3 | * 4 | * See https://typescript-eslint.io/linting/typed-linting/ 5 | * See https://typescript-eslint.io/linting/typed-linting/monorepos 6 | * 7 | * One must add the `parserOptions` field in eslint configuration. This will configure the `typescript-eslint` parser. 8 | * 9 | * More specifically, it's required to set `project` and recommended to set `tsconfigRootDir`. See the README.md for more information on how it could be setup 10 | */ 11 | 12 | /** 13 | * These are very useful but also very strict eslint rules requiring everything 14 | * to be typed without `any` etc. We should strive to enable them down the line 15 | */ 16 | const typescriptTypeInformationChecksDisabled = { 17 | '@typescript-eslint/no-unsafe-argument': 'off', 18 | '@typescript-eslint/no-unsafe-assignment': 'off', 19 | '@typescript-eslint/no-unsafe-call': 'off', 20 | '@typescript-eslint/no-unsafe-member-access': 'off', 21 | '@typescript-eslint/no-unsafe-return': 'off', 22 | '@typescript-eslint/restrict-template-expressions': 'off', 23 | '@typescript-eslint/unbound-method': 'off', 24 | }; 25 | exports.typescriptTypeInformationChecksDisabled = 26 | typescriptTypeInformationChecksDisabled; 27 | 28 | module.exports = { 29 | extends: [ 30 | './typescript', 31 | 'plugin:@typescript-eslint/recommended-requiring-type-checking', 32 | ], 33 | rules: { 34 | ...typescriptTypeInformationChecksDisabled, 35 | '@typescript-eslint/no-misused-promises': [ 36 | 'error', 37 | { checksVoidReturn: false }, 38 | ], 39 | '@typescript-eslint/no-unnecessary-condition': 'error', 40 | '@typescript-eslint/no-unnecessary-type-assertion': 'error', 41 | '@typescript-eslint/prefer-regexp-exec': 'off', 42 | '@typescript-eslint/strict-boolean-expressions': [ 43 | 'error', 44 | { 45 | allowNullableBoolean: true, // Allowed because otherwise there are quite some false positives 46 | allowNullableObject: false, 47 | allowNumber: false, 48 | allowString: false, 49 | }, 50 | ], 51 | }, 52 | }; 53 | -------------------------------------------------------------------------------- /packages/eslint-config-datacamp/typescript.js: -------------------------------------------------------------------------------- 1 | const { testFilesGlobPatterns } = require('./helpers'); 2 | 3 | module.exports = { 4 | extends: [ 5 | './index', 6 | 'plugin:import/typescript', 7 | 'plugin:@typescript-eslint/recommended', 8 | ], 9 | overrides: [ 10 | { 11 | files: testFilesGlobPatterns, 12 | rules: { 13 | '@typescript-eslint/ban-ts-comment': 'off', 14 | '@typescript-eslint/ban-ts-ignore': 'off', 15 | '@typescript-eslint/no-empty-function': 'off', 16 | '@typescript-eslint/no-explicit-any': 'off', 17 | '@typescript-eslint/no-non-null-assertion': 'off', 18 | '@typescript-eslint/ts-expect-error': 'off', 19 | }, 20 | }, 21 | ], 22 | plugins: ['json', 'typescript-sort-keys', 'prefer-type-alias'], 23 | rules: { 24 | '@typescript-eslint/array-type': ['error', { default: 'array-simple' }], 25 | '@typescript-eslint/ban-ts-comment': 'error', 26 | '@typescript-eslint/consistent-type-imports': [ 27 | 'error', 28 | { 29 | prefer: 'type-imports', 30 | }, 31 | ], 32 | '@typescript-eslint/explicit-function-return-type': 'off', 33 | '@typescript-eslint/explicit-module-boundary-types': 'off', 34 | '@typescript-eslint/naming-convention': [ 35 | 'error', 36 | { 37 | custom: { 38 | match: false, 39 | regex: '^I[A-Z]', 40 | }, 41 | format: ['PascalCase'], 42 | selector: 'interface', 43 | }, 44 | ], 45 | '@typescript-eslint/no-explicit-any': 'error', 46 | '@typescript-eslint/no-non-null-assertion': 'error', 47 | '@typescript-eslint/no-unused-vars': [ 48 | 'error', 49 | { 50 | argsIgnorePattern: '^_', 51 | varsIgnorePattern: '^_', 52 | }, 53 | ], 54 | '@typescript-eslint/no-use-before-define': 'error', 55 | '@typescript-eslint/prefer-ts-expect-error': 'error', 56 | '@typescript-eslint/sort-type-union-intersection-members': 'error', 57 | 'import/extensions': [ 58 | 'error', 59 | 'ignorePackages', 60 | { 61 | js: 'never', 62 | jsx: 'never', 63 | ts: 'never', 64 | tsx: 'never', 65 | }, 66 | ], 67 | 'no-underscore-dangle': 'off', 68 | 'no-use-before-define': 'off', 69 | 'prefer-type-alias/prefer-type-alias': 'error', 70 | 'react/prop-types': 'off', 71 | 'typescript-sort-keys/interface': [ 72 | 'error', 73 | 'asc', 74 | { caseSensitive: false, natural: true }, 75 | ], 76 | 'typescript-sort-keys/string-enum': [ 77 | 'error', 78 | 'asc', 79 | { caseSensitive: false, natural: true }, 80 | ], 81 | }, 82 | }; 83 | -------------------------------------------------------------------------------- /packages/prettier-config-datacamp/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [3.0.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/prettier-config@2.1.0...@datacamp/prettier-config@3.0.0) (2021-08-04) 7 | 8 | 9 | ### chore 10 | 11 | * bump prettier to v2.3.2 ([b124c6b](https://github.com/datacamp-engineering/jsconfig/commit/b124c6b91ebf4d1935a77ea5ecfbd338587df4fc)) 12 | 13 | 14 | ### BREAKING CHANGES 15 | 16 | * compatability concerns with eslint 17 | 18 | 19 | 20 | 21 | 22 | # [2.1.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/prettier-config@2.0.0...@datacamp/prettier-config@2.1.0) (2020-07-30) 23 | 24 | 25 | ### Features 26 | 27 | * adds repository info to package.json files ([5a28357](https://github.com/datacamp-engineering/jsconfig/commit/5a28357)) 28 | 29 | 30 | 31 | 32 | 33 | # [2.0.0](https://github.com/datacamp-engineering/jsconfig/compare/@datacamp/prettier-config@0.1.0...@datacamp/prettier-config@2.0.0) (2020-07-29) 34 | 35 | 36 | ### Bug Fixes 37 | 38 | * **prettier:** bump version number ([db263fc](https://github.com/datacamp-engineering/jsconfig/commit/db263fc)) 39 | * **prettier:** remove default settings ([e532898](https://github.com/datacamp-engineering/jsconfig/commit/e532898)) 40 | 41 | 42 | ### Features 43 | 44 | * bump prettier version to v2 ([b4586c8](https://github.com/datacamp-engineering/jsconfig/commit/b4586c8)) 45 | 46 | 47 | ### BREAKING CHANGES 48 | 49 | * **prettier:** If you already upgraded to prettier 2.x, some settings will have a new value 50 | e.g. `arrowParens` will now have the value `always` instead of `avoid` 51 | 52 | 53 | 54 | 55 | 56 | # 0.1.0 (2020-02-13) 57 | 58 | 59 | ### Bug Fixes 60 | 61 | * Add homepage to package.json ([#51](https://github.com/datacamp-engineering/jsconfig/issues/51)) ([04fd7fd](https://github.com/datacamp-engineering/jsconfig/commit/04fd7fd)) 62 | 63 | 64 | ### Features 65 | 66 | * **prettier:** Add initial prettier config ([1eeeab5](https://github.com/datacamp-engineering/jsconfig/commit/1eeeab5)) 67 | -------------------------------------------------------------------------------- /packages/prettier-config-datacamp/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | overrides: [ 3 | { 4 | files: ['*.json'], 5 | options: { parser: 'json' }, 6 | }, 7 | ], 8 | singleQuote: true, 9 | trailingComma: 'all', 10 | }; 11 | -------------------------------------------------------------------------------- /packages/prettier-config-datacamp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@datacamp/prettier-config", 3 | "version": "4.0.0", 4 | "main": "index.js", 5 | "files": [ 6 | "*.js", 7 | "CHANGELOG.md" 8 | ], 9 | "peerDependencies": { 10 | "prettier": "^2.8.4" 11 | }, 12 | "homepage": "https://github.com/datacamp-engineering/jsconfig", 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/datacamp-engineering/jsconfig.git", 16 | "directory": "packages/prettier-config-datacamp" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ...require('./packages/prettier-config-datacamp'), 3 | }; 4 | --------------------------------------------------------------------------------