From 1edbeecbe565cbbbc0a6e6532c7c2d0c58d78807 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 24 Mar 2019 00:50:26 -0700 Subject: [PATCH] chore(v2): add ESLint rule to check for Facebook copyright headers in JS files (#1301) --- .eslintignore | 2 ++ .eslintrc.js | 22 +++++++++++++--- package.json | 25 +++++++++++-------- packages/docusaurus-1.x/.eslintignore | 4 --- packages/docusaurus/lib/load/docs/metadata.js | 2 +- yarn.lock | 5 ++++ 6 files changed, 42 insertions(+), 18 deletions(-) delete mode 100644 packages/docusaurus-1.x/.eslintignore diff --git a/.eslintignore b/.eslintignore index 691f67e41c..839e0614c4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,3 +7,5 @@ jest.transform.js website-1.x/ website/ scripts +packages/docusaurus-1.x/lib/core/metadata.js +packages/docusaurus-1.x/lib/core/MetadataBlog.js diff --git a/.eslintrc.js b/.eslintrc.js index 0c29a5afb6..214c41daf3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,20 +21,36 @@ module.exports = { allowImportExportEverywhere: true, }, extends: ['airbnb', 'prettier', 'prettier/react'], - plugins: ['react-hooks'], + plugins: ['react-hooks', 'header'], rules: { 'class-methods-use-this': OFF, // It's a way of allowing private variables. - 'no-console': OFF, 'func-names': OFF, + 'import/no-unresolved': WARNING, // Because it couldn't resolve webpack alias. + 'header/header': [ + ERROR, + 'block', + [ + '*', + { + pattern: + ' \\* Copyright \\(c\\) \\d{4}-present\\, Facebook\\, Inc\\.', + template: ' * Copyright (c) 2017-present, Facebook, Inc.', + }, + ' *', + ' * This source code is licensed under the MIT license found in the', + ' * LICENSE file in the root directory of this source tree.', + ' ', + ], + ], 'jsx-a11y/click-events-have-key-events': OFF, // Revisit in future™ 'jsx-a11y/no-noninteractive-element-interactions': OFF, // Revisit in future™ + 'no-console': OFF, 'react/jsx-closing-bracket-location': OFF, // Conflicts with Prettier. 'react/jsx-filename-extension': OFF, 'react/jsx-one-expression-per-line': OFF, 'react/no-array-index-key': OFF, // Sometimes its ok, e.g. non-changing data. 'react/prop-types': OFF, 'react/destructuring-assignment': OFF, // Too many lines. - 'import/no-unresolved': WARNING, // Because it couldn't resolve webpack alias. 'react/prefer-stateless-function': WARNING, 'react-hooks/rules-of-hooks': ERROR, }, diff --git a/package.json b/package.json index a661e67008..d0bb32d369 100644 --- a/package.json +++ b/package.json @@ -13,30 +13,35 @@ "test": "jest" }, "devDependencies": { - "lerna": "^3.13.1", - "husky": "^1.3.1", - "lint-staged": "^7.2.0", - "prettier": "^1.13.7", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "8", "eslint": "4.x", "eslint-config-airbnb": "17.1.0", "eslint-config-prettier": "^2.9.0", + "eslint-plugin-header": "^3.0.0", "eslint-plugin-import": "^2.14.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.11.1", "eslint-plugin-react-hooks": "^0.0.0", - "jest": "^24.1.0", - "react": "^16.8.4", - "react-dom": "^16.8.4", "filepath": "^1.1.0", "front-matter": "^2.3.0", - "rimraf": "^2.6.2", - "glob-promise": "^3.3.0" + "glob-promise": "^3.3.0", + "husky": "^1.3.1", + "jest": "^24.1.0", + "lerna": "^3.13.1", + "lint-staged": "^7.2.0", + "prettier": "^1.13.7", + "react": "^16.8.4", + "react-dom": "^16.8.4", + "rimraf": "^2.6.2" }, "lint-staged": { "linters": { - "*.js": ["yarn lint --fix", "yarn prettier", "git add"] + "*.js": [ + "yarn lint --fix", + "yarn prettier", + "git add" + ] } }, "husky": { diff --git a/packages/docusaurus-1.x/.eslintignore b/packages/docusaurus-1.x/.eslintignore deleted file mode 100644 index 78fcb7b079..0000000000 --- a/packages/docusaurus-1.x/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -static/**/*.js -build -node_modules -v2 diff --git a/packages/docusaurus/lib/load/docs/metadata.js b/packages/docusaurus/lib/load/docs/metadata.js index a325628dda..3985e67574 100644 --- a/packages/docusaurus/lib/load/docs/metadata.js +++ b/packages/docusaurus/lib/load/docs/metadata.js @@ -1,4 +1,4 @@ -/* +/** * Copyright (c) 2017-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the diff --git a/yarn.lock b/yarn.lock index d0eef68917..b55a776281 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4915,6 +4915,11 @@ eslint-module-utils@^2.3.0: debug "^2.6.8" pkg-dir "^2.0.0" +eslint-plugin-header@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-header/-/eslint-plugin-header-3.0.0.tgz#0e048b5f0adfdd9754142d59d551ae6bfdaf90ad" + integrity sha512-OIu2ciVW8jK4Ove4JHm1I7X0C98PZuLCyCsoUhAm2HpyGS+zr34qLM6iV06unnDvssvvEh5BkOfaLRF+N7cGoQ== + eslint-plugin-import@^2.14.0: version "2.16.0" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.16.0.tgz#97ac3e75d0791c4fac0e15ef388510217be7f66f"