From ba48c36ee88a7202b064452ce12be161da24a089 Mon Sep 17 00:00:00 2001 From: Chapman Pendery Date: Sun, 8 Oct 2023 01:45:20 -0700 Subject: [PATCH] refactor: add eslint header plugin with copywright text Signed-off-by: Chapman Pendery --- .eslintrc.cjs | 7 +++++-- jest.config.cjs | 3 +++ package-lock.json | 17 +++++++++++++++++ package.json | 3 ++- src/commands/bind.ts | 3 +++ src/commands/root.ts | 3 +++ src/index.ts | 5 +++++ src/runtime/generator.ts | 3 +++ src/runtime/model.ts | 3 +++ src/runtime/parser.ts | 3 +++ src/runtime/runtime.ts | 3 +++ src/runtime/suggestion.ts | 3 +++ src/runtime/template.ts | 3 +++ src/runtime/utils.ts | 3 +++ src/tests/runtime/parser.test.ts | 3 +++ src/tests/runtime/runtime.test.ts | 3 +++ src/ui/input.tsx | 3 +++ src/ui/suggestions.tsx | 3 +++ src/ui/ui-bind.tsx | 3 +++ src/ui/ui-root.tsx | 3 +++ src/utils/bindings.ts | 3 +++ src/utils/cache.ts | 3 +++ 22 files changed, 83 insertions(+), 3 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 395bf7a..859dbd0 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + module.exports = { env: { es2021: true, @@ -20,8 +23,8 @@ module.exports = { ecmaVersion: "latest", sourceType: "module", }, - plugins: ["@typescript-eslint", "react"], - rules: {}, + plugins: ["@typescript-eslint", "react", "header"], + rules: { "header/header": [2, "line", [" Copyright (c) Microsoft Corporation.", " Licensed under the MIT License."]] }, settings: { react: { version: "detect", diff --git a/jest.config.cjs b/jest.config.cjs index 3f98ef0..d85552c 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { // [...] diff --git a/package-lock.json b/package-lock.json index 1d26ea1..fec1cd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "@withfig/autocomplete-types": "^1.28.0", "eslint": "^8.51.0", "eslint-config-prettier": "^9.0.0", + "eslint-plugin-header": "^3.1.1", "eslint-plugin-react": "^7.33.2", "jest": "^29.7.0", "prettier": "3.0.3", @@ -3314,6 +3315,15 @@ "eslint": ">=7.0.0" } }, + "node_modules/eslint-plugin-header": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", + "integrity": "sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==", + "dev": true, + "peerDependencies": { + "eslint": ">=7.7.0" + } + }, "node_modules/eslint-plugin-react": { "version": "7.33.2", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.33.2.tgz", @@ -10513,6 +10523,13 @@ "dev": true, "requires": {} }, + "eslint-plugin-header": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-header/-/eslint-plugin-header-3.1.1.tgz", + "integrity": "sha512-9vlKxuJ4qf793CmeeSrZUvVClw6amtpghq3CuWcB5cUNnWHQhgcqy5eF8oVKFk1G3Y/CbchGfEaw3wiIJaNmVg==", + "dev": true, + "requires": {} + }, "eslint-plugin-react": { "version": "7.33.2", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.33.2.tgz", diff --git a/package.json b/package.json index 11d2878..561c20e 100644 --- a/package.json +++ b/package.json @@ -48,10 +48,11 @@ "@withfig/autocomplete-types": "^1.28.0", "eslint": "^8.51.0", "eslint-config-prettier": "^9.0.0", + "eslint-plugin-header": "^3.1.1", "eslint-plugin-react": "^7.33.2", "jest": "^29.7.0", "prettier": "3.0.3", "ts-jest": "^29.1.1", "typescript": "^5.2.2" } -} \ No newline at end of file +} diff --git a/src/commands/bind.ts b/src/commands/bind.ts index 9fff237..2ad7cd7 100644 --- a/src/commands/bind.ts +++ b/src/commands/bind.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { Command } from "commander"; import { supportedShells } from "../utils/bindings.js"; import { render } from "../ui/ui-bind.js"; diff --git a/src/commands/root.ts b/src/commands/root.ts index eb2fb9b..e623cc7 100644 --- a/src/commands/root.ts +++ b/src/commands/root.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { render } from "../ui/ui-root.js"; import { executeShellCommandTTY } from "../runtime/utils.js"; import { saveCommand, loadCommand } from "../utils/cache.js"; diff --git a/src/index.ts b/src/index.ts index 674e950..bbdde8c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,10 @@ #!/usr/bin/env node +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/* eslint-disable header/header */ + import { Command } from "commander"; import bind from "./commands/bind.js"; diff --git a/src/runtime/generator.ts b/src/runtime/generator.ts index d4fab42..96ca02b 100644 --- a/src/runtime/generator.ts +++ b/src/runtime/generator.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { runTemplates } from "./template.js"; import { buildExecuteShellCommand } from "./utils.js"; diff --git a/src/runtime/model.ts b/src/runtime/model.ts index 52b2076..896ab4b 100644 --- a/src/runtime/model.ts +++ b/src/runtime/model.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + export type Suggestion = { name: string; allNames: string[]; diff --git a/src/runtime/parser.ts b/src/runtime/parser.ts index 02f5840..4416d3c 100644 --- a/src/runtime/parser.ts +++ b/src/runtime/parser.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + export type CommandToken = { token: string; complete: boolean; diff --git a/src/runtime/runtime.ts b/src/runtime/runtime.ts index af2a859..08a45ea 100644 --- a/src/runtime/runtime.ts +++ b/src/runtime/runtime.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import speclist, { diffVersionedCompletions as versionedSpeclist, // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/src/runtime/suggestion.ts b/src/runtime/suggestion.ts index d09e2ff..cd49229 100644 --- a/src/runtime/suggestion.ts +++ b/src/runtime/suggestion.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { CommandToken } from "./parser.js"; import { runGenerator } from "./generator.js"; import { runTemplates } from "./template.js"; diff --git a/src/runtime/template.ts b/src/runtime/template.ts index 27108b1..80021ec 100644 --- a/src/runtime/template.ts +++ b/src/runtime/template.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import fsAsync from "fs/promises"; import process from "node:process"; diff --git a/src/runtime/utils.ts b/src/runtime/utils.ts index bdf2d77..84e6428 100644 --- a/src/runtime/utils.ts +++ b/src/runtime/utils.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { exec, spawn } from "node:child_process"; type ExecuteShellCommandTTYResult = { diff --git a/src/tests/runtime/parser.test.ts b/src/tests/runtime/parser.test.ts index ed79ba4..8d200bb 100644 --- a/src/tests/runtime/parser.test.ts +++ b/src/tests/runtime/parser.test.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { parseCommand } from "../../runtime/parser.js"; const testData = [ diff --git a/src/tests/runtime/runtime.test.ts b/src/tests/runtime/runtime.test.ts index 8e946e1..87744e0 100644 --- a/src/tests/runtime/runtime.test.ts +++ b/src/tests/runtime/runtime.test.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { getSuggestions } from "../../runtime/runtime.js"; const testData = [ diff --git a/src/ui/input.tsx b/src/ui/input.tsx index e5c9c76..c691cef 100644 --- a/src/ui/input.tsx +++ b/src/ui/input.tsx @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import React, { useState, useEffect } from "react"; import { useInput, Text } from "ink"; import chalk from "chalk"; diff --git a/src/ui/suggestions.tsx b/src/ui/suggestions.tsx index abd7ca3..a8fd54e 100644 --- a/src/ui/suggestions.tsx +++ b/src/ui/suggestions.tsx @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import React, { useState, useCallback, useEffect } from "react"; import { Text, useInput, Box, measureElement, DOMElement } from "ink"; import wrapAnsi from "wrap-ansi"; diff --git a/src/ui/ui-bind.tsx b/src/ui/ui-bind.tsx index 4cff19c..42360ae 100644 --- a/src/ui/ui-bind.tsx +++ b/src/ui/ui-bind.tsx @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import React, { useEffect, useState } from "react"; import { Box, Text, render as inkRender, useInput, useApp } from "ink"; import chalk from "chalk"; diff --git a/src/ui/ui-root.tsx b/src/ui/ui-root.tsx index 1627953..0656c93 100644 --- a/src/ui/ui-root.tsx +++ b/src/ui/ui-root.tsx @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import React, { useCallback, useEffect, useState } from "react"; import { Text, Box, render as inkRender, measureElement, DOMElement, useInput, useApp } from "ink"; import wrapAnsi from "wrap-ansi"; diff --git a/src/utils/bindings.ts b/src/utils/bindings.ts index 563ed83..8339810 100644 --- a/src/utils/bindings.ts +++ b/src/utils/bindings.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import os from "node:os"; import path from "node:path"; import fsAsync from "node:fs/promises"; diff --git a/src/utils/cache.ts b/src/utils/cache.ts index d86061c..e41f46e 100644 --- a/src/utils/cache.ts +++ b/src/utils/cache.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import os from "node:os"; import path from "node:path"; import fsAsync from "node:fs/promises";