Skip to content

Commit

Permalink
Added license headers to TypeScript files. (#311)
Browse files Browse the repository at this point in the history
* Added license headers jest linter.

Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock authored Jun 4, 2024
1 parent 0fcf9f7 commit 6bdfbc3
Show file tree
Hide file tree
Showing 69 changed files with 624 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added workflow to determine API changes ([#297](https://github.com/opensearch-project/opensearch-api-specification/pull/297))
- Added link checking ([#269](https://github.com/opensearch-project/opensearch-api-specification/pull/269))
- Added API coverage ([#210](https://github.com/opensearch-project/opensearch-api-specification/pull/210))
- Added license headers to TypeScript code ([#311](https://github.com/opensearch-project/opensearch-api-specification/pull/311))

### Changed

Expand Down
19 changes: 18 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path'
import { fileURLToPath } from 'url'
import { FlatCompat } from '@eslint/eslintrc'
import pluginJs from '@eslint/js'
import licenseHeader from 'eslint-plugin-license-header'

// mimic CommonJS variables -- not needed if using CommonJS
const _filename = fileURLToPath(import.meta.url)
Expand All @@ -13,6 +14,9 @@ export default [
...compat.extends('standard-with-typescript'),
{
files: ['**/*.{js,ts}'],
plugins: {
'license-header': licenseHeader
},
rules: {
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
Expand Down Expand Up @@ -51,7 +55,20 @@ export default [
'array-callback-return': 'off',
'new-cap': 'off',
'no-return-assign': 'error',
'object-shorthand': 'error'
'object-shorthand': 'error',
'license-header/header': [
'error',
[
'/*',
'* Copyright OpenSearch Contributors',
'* SPDX-License-Identifier: Apache-2.0',
'*',
'* The OpenSearch Contributors require contributions made to',
'* this file be licensed under the Apache-2.0 license or a',
'* compatible open source license.',
'*/'
]
]
}
}
]
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"eslint": "^8.57.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-license-header": "^0.6.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"globals": "^15.0.0",
Expand Down
9 changes: 9 additions & 0 deletions tools/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import fs from 'fs'
import path from 'path'
import YAML from 'yaml'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

export enum LogLevel {
error = 1,
warn = 2,
Expand Down
9 changes: 9 additions & 0 deletions tools/src/coverage/CoverageCalculator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { type OpenAPIV3 } from 'openapi-types'
import { HTTP_METHODS, read_yaml, write_json } from '../../helpers'

Expand Down
9 changes: 9 additions & 0 deletions tools/src/coverage/coverage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { Command, Option } from '@commander-js/extra-typings'
import CoverageCalculator from './CoverageCalculator'
import { resolve } from 'path'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/dump-cluster-spec/dump-cluster-spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { Command, Option } from '@commander-js/extra-typings'
import { resolve } from 'path'
import axios from 'axios'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/InlineObjectSchemaValidator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import type NamespacesFolder from './components/NamespacesFolder'
import type SchemasFolder from './components/SchemasFolder'
import { type ValidationError } from 'types'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/SchemaRefsValidator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import type NamespacesFolder from './components/NamespacesFolder'
import type SchemasFolder from './components/SchemasFolder'
import { type ValidationError } from 'types'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/SchemasValidator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import AJV from 'ajv'
import addFormats from 'ajv-formats'
import OpenApiMerger from '../merger/OpenApiMerger'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/SpecValidator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import SchemasFolder from './components/SchemasFolder'
import NamespacesFolder from './components/NamespacesFolder'
import { type ValidationError } from 'types'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/InfoFile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import FileValidator from './base/FileValidator'

export default class InfoFile extends FileValidator {
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/NamespaceFile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { type OpenAPIV3 } from 'openapi-types'
import { type OperationSpec, type ValidationError } from 'types'
import OperationGroup from './OperationGroup'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/NamespacesFolder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import NamespaceFile from './NamespaceFile'
import { type ValidationError } from 'types'
import FolderValidator from './base/FolderValidator'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/Operation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { type OperationSpec, type ValidationError } from 'types'
import _ from 'lodash'
import ValidatorBase from './base/ValidatorBase'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/OperationGroup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import type Operation from './Operation'
import { type ValidationError } from 'types'
import ValidatorBase from './base/ValidatorBase'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/Schema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import ValidatorBase from './base/ValidatorBase'
import { type OpenAPIV3 } from 'openapi-types'
import { type ValidationError } from 'types'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/SchemaFile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import FileValidator from './base/FileValidator'
import { type ValidationError } from 'types'
import Schema from './Schema'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/SchemasFolder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import SchemaFile from './SchemaFile'
import FolderValidator from './base/FolderValidator'
import { type ValidationError } from 'types'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/SupersededOperationsFile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import FileValidator from './base/FileValidator'

export default class SupersededOperationsFile extends FileValidator {
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/base/FileValidator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import ValidatorBase from './ValidatorBase'
import { type ValidationError } from 'types'
import { type OpenAPIV3 } from 'openapi-types'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/base/FolderValidator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import fs from 'fs'
import ValidatorBase from './ValidatorBase'
import type FileValidator from './FileValidator'
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/components/base/ValidatorBase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { type ValidationError } from 'types'
export default class ValidatorBase {
file: string
Expand Down
9 changes: 9 additions & 0 deletions tools/src/linter/lint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

import { Command, Option } from '@commander-js/extra-typings'
import SpecValidator from './SpecValidator'
import { resolve } from 'path'
Expand Down
Loading

0 comments on commit 6bdfbc3

Please sign in to comment.