Skip to content

Commit

Permalink
chore: lint ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Mar 15, 2021
1 parent 256168a commit cc255ab
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 32 deletions.
37 changes: 37 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##
# The MIT License (MIT)
#
# Copyright (c) 2016-2020 Mickael Jeanroy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
##

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

# Indentation override for all JS under lib directory
[*.{js,ts,json,yml}]
indent_style = space
indent_size = 2
30 changes: 29 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,33 @@
"object": "object"
}
}]
}
},
"overrides": [
{
"files": [
"**/*.ts"
],
"env": {
"browser": true,
"es6": true,
"node": false
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"comma-dangle": ["error", "always-multiline"],
"@typescript-eslint/no-explicit-any": 0
}
}
]
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
##

*.js text eol=lf
*.ts text eol=lf
*.txt text eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
/dist
/npm-debug.log
/package-lock.json
/.idea
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
"@rollup/plugin-babel": "5.3.0",
"@rollup/plugin-commonjs": "17.1.0",
"@rollup/plugin-node-resolve": "11.2.0",
"@typescript-eslint/parser": "4.17.0",
"@typescript-eslint/eslint-plugin": "4.17.0",
"babel-plugin-add-module-exports": "1.0.4",
"eslint": "7.21.0",
"eslint-config-google": "0.14.0",
Expand All @@ -70,7 +72,8 @@
"rollup": "2.41.1",
"rollup-plugin-prettier": "2.1.0",
"rollup-plugin-strip-banner": "2.0.0",
"tmp": "0.2.1"
"tmp": "0.2.1",
"typescript": "4.2.3"
},
"engines": {
"node": ">=10.0.0"
Expand Down
5 changes: 5 additions & 0 deletions scripts/lint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ module.exports = function lint() {
path.join(config.src, '**', '*.js'),
path.join(config.test, '**', '*.js'),
path.join(config.scripts, '**', '*.js'),

path.join(config.root, '*.ts'),
path.join(config.src, '**', '*.ts'),
path.join(config.test, '**', '*.ts'),
path.join(config.scripts, '**', '*.ts'),
];

log.debug('Linting files: ');
Expand Down
58 changes: 28 additions & 30 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* SOFTWARE.
*/

import type { Plugin } from "rollup";
import type {Plugin} from 'rollup';

export interface Person {
readonly name: string,
Expand All @@ -33,18 +33,17 @@ export interface Person {
* Turns the person into a formatted string
* @returns formatted person info
*/
text: ()=> string,
text: () => string,
}

export type CommentStyle = "regular" | "ignored" | "slash";
export type CommentStyle = 'regular' | 'ignored' | 'slash';

export type Banner = string | {
/**
* @see {@link https://github.com/mjeanroy/rollup-plugin-license#comment-style}
*/
commentStyle?: CommentStyle,
content: string | (()=> string) | {

content: string | (() => string) | {
/**
* File to get banner content from
*/
Expand All @@ -55,7 +54,7 @@ export type Banner = string | {
*/
encoding?: string,
},
data?: {[key: string]: string} | (()=> {[key: string]: string}),
data?: { [key: string]: string } | (() => { [key: string]: string }),
};

/**
Expand Down Expand Up @@ -97,10 +96,10 @@ export interface Dependency {
* Turns the dependency into a formatted string
* @returns formatted dependency license info
*/
text: ()=> string,
text: () => string,
}

export type ThirdPartyOutput = string | ((dependencies: Dependency[])=> void) | {
export type ThirdPartyOutput = string | ((dependencies: Dependency[]) => void) | {

/**
* Name of file to write licenses to
Expand All @@ -120,18 +119,18 @@ export type ThirdPartyOutput = string | ((dependencies: Dependency[])=> void) |
* `${dependency.name}:${dependency.version} -- ${dependency.license}`).join('\n')
* );
* },
*
*
* // Lodash template that can be defined to customize report output
* template: `
* <% _.forEach(dependencies, function (dependency) { %>
* <%= dependency.name %>:<%= dependency.version%> -- <%= dependency.license %>
* <% }) %>
* `
*/
template?: ((dependencies: Dependency[])=> string) | string,
template?: ((dependencies: Dependency[]) => string) | string,
};

export type ThirdParty = ((dependencies: Dependency[])=> void) | {
export type ThirdParty = ((dependencies: Dependency[]) => void) | {
/**
* If private dependencies should be allowed (`private: true` in package.json)
* @default false
Expand All @@ -144,33 +143,32 @@ export type ThirdParty = ((dependencies: Dependency[])=> void) | {
* licenses, simply define the restriction such as:
* @example
* {allow: '(MIT OR Apache-2.0)'}
*
*
* allow(dependency) {
* return dependency.license === 'MIT';
* }
*/
allow?: string | ((dependency: Dependency)=> boolean) | {

/**
* Testing if the license if valid
*/
test: string | ((dependency: Dependency)=> boolean),
allow?: string | ((dependency: Dependency) => boolean) | {
/**
* Testing if the license if valid
*/
test: string | ((dependency: Dependency) => boolean),

/**
* Fail if a dependency does not specify any licenses
* @default false
*/
failOnUnlicensed?: boolean,
/**
* Fail if a dependency does not specify any licenses
* @default false
*/
failOnUnlicensed?: boolean,

/**
* Fail if a dependency specify a license that does not match given requirement
* @default false
*/
failOnViolation?: boolean,
/**
* Fail if a dependency specify a license that does not match given requirement
* @default false
*/
failOnViolation?: boolean,
},

/**
* Output file for
* Output file for
*/
output: ThirdPartyOutput | ThirdPartyOutput[],
};
Expand Down Expand Up @@ -205,4 +203,4 @@ export type Options = {

declare function rollupPluginLicense(options: Options): Plugin;

export default rollupPluginLicense
export default rollupPluginLicense;

0 comments on commit cc255ab

Please sign in to comment.