@studyportals/code-style
Advanced tools
Comparing version 2.0.0-alpha.0 to 2.0.0
440
.eslintrc.js
//http://eslint.org/docs/rules/ | ||
module.exports = { | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"browser": true | ||
env: { | ||
es6: true, | ||
node: true, | ||
browser: true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 2017 | ||
parserOptions: { | ||
sourceType: "module", | ||
ecmaVersion: 2017 | ||
}, | ||
"extends": "eslint:recommended", | ||
"rules": { | ||
"no-console": ["error", { | ||
allow: [ | ||
"warn", | ||
"dir", | ||
"time", | ||
"timeEnd", | ||
"timeLog", | ||
"trace", | ||
"assert", | ||
"clear", | ||
"count", | ||
"countReset", | ||
"group", | ||
"groupEnd", | ||
"table", | ||
"dirxml", | ||
"error", | ||
"groupCollapsed", | ||
"Console", | ||
"profile", | ||
"profileEnd", | ||
"timeStamp", | ||
"context" | ||
] | ||
}], | ||
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"] | ||
}, | ||
overrides: [{ | ||
files: ["*.ts", "*.tsx"], | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "tsconfig.json", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"eslint-plugin-import", | ||
"eslint-plugin-jsdoc", | ||
"eslint-plugin-prefer-arrow", | ||
"@typescript-eslint", | ||
"@typescript-eslint/tslint" | ||
], | ||
"rules": { | ||
"@typescript-eslint/adjacent-overload-signatures": "off", | ||
"@typescript-eslint/array-type": [ | ||
"error", | ||
{ | ||
"default": "array" | ||
} | ||
], | ||
"@typescript-eslint/ban-types": [ | ||
"error", | ||
{ | ||
"types": { | ||
"Object": { | ||
"message": "Avoid using the `Object` type. Did you mean `object`?" | ||
}, | ||
"Function": { | ||
"message": "Avoid using the `Function` type. Prefer a specific function type, like `() => void`." | ||
}, | ||
"Boolean": { | ||
"message": "Avoid using the `Boolean` type. Did you mean `boolean`?" | ||
}, | ||
"Number": { | ||
"message": "Avoid using the `Number` type. Did you mean `number`?" | ||
}, | ||
"String": { | ||
"message": "Avoid using the `String` type. Did you mean `string`?" | ||
}, | ||
"Symbol": { | ||
"message": "Avoid using the `Symbol` type. Did you mean `symbol`?" | ||
} | ||
} | ||
} | ||
], | ||
"@typescript-eslint/consistent-type-assertions": "error", | ||
"@typescript-eslint/dot-notation": "off", | ||
"@typescript-eslint/explicit-function-return-type": "error", | ||
"@typescript-eslint/indent": [ | ||
"error", | ||
"tab" | ||
], | ||
"@typescript-eslint/member-ordering": "off", | ||
"@typescript-eslint/naming-convention": [ | ||
"error", | ||
{ | ||
"selector": 'variable', | ||
"format": ['camelCase', 'UPPER_CASE', 'snake_case'], | ||
"leadingUnderscore": 'allow', | ||
"trailingUnderscore": 'forbid', | ||
}, | ||
{ | ||
"selector": 'function', | ||
"format": ['camelCase'], | ||
"leadingUnderscore": 'allow', | ||
"trailingUnderscore": 'forbid', | ||
}, | ||
{ | ||
"selector": 'typeLike', | ||
"format": ['PascalCase'], | ||
}, | ||
{ | ||
"selector": 'enumMember', | ||
"format": ['UPPER_CASE'] | ||
} | ||
], | ||
"@typescript-eslint/no-empty-function": "error", | ||
"@typescript-eslint/no-empty-interface": "error", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-misused-new": "error", | ||
"@typescript-eslint/no-namespace": "off", | ||
"@typescript-eslint/no-parameter-properties": "off", | ||
"@typescript-eslint/no-unused-expressions": "error", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/no-var-requires": "error", | ||
"@typescript-eslint/prefer-for-of": "error", | ||
"@typescript-eslint/prefer-function-type": "off", | ||
"@typescript-eslint/prefer-namespace-keyword": "off", | ||
"@typescript-eslint/triple-slash-reference": [ | ||
"error", | ||
{ | ||
"path": "always", | ||
"types": "prefer-import", | ||
"lib": "always" | ||
} | ||
], | ||
"@typescript-eslint/unified-signatures": "error", | ||
"@typescript-eslint/no-shadow": [ | ||
"error", | ||
{ | ||
"hoist": "all" | ||
} | ||
], | ||
"@typescript-eslint/no-unsafe-member-access": "warn", | ||
"arrow-parens": [ | ||
"off", | ||
"always" | ||
], | ||
"comma-dangle": [ | ||
"error", | ||
{ | ||
"objects": "never", | ||
"arrays": "never", | ||
"functions": "never" | ||
} | ||
], | ||
"complexity": "off", | ||
"constructor-super": "error", | ||
"eol-last": "off", | ||
"eqeqeq": [ | ||
"error", | ||
"smart" | ||
], | ||
"guard-for-in": "off", | ||
"id-denylist": [ | ||
"error", | ||
"any", | ||
"Number", | ||
"number", | ||
"String", | ||
"string", | ||
"Boolean", | ||
"boolean", | ||
"Undefined", | ||
"undefined" | ||
], | ||
"id-match": "off", | ||
"import/order": "off", | ||
"jsdoc/check-alignment": "error", | ||
"jsdoc/check-indentation": "error", | ||
"jsdoc/newline-after-description": "error", | ||
"max-classes-per-file": [ | ||
"error", | ||
1 | ||
], | ||
"max-len": [ | ||
"warn", | ||
{ | ||
"code": 140 | ||
} | ||
], | ||
"new-parens": "off", | ||
"no-bitwise": "error", | ||
"no-caller": "error", | ||
"no-cond-assign": "error", | ||
extends: "eslint:recommended", | ||
rules: { | ||
"no-console": [ | ||
"error", | ||
{ | ||
"allow": [ | ||
allow: [ | ||
"warn", | ||
@@ -230,41 +42,195 @@ "dir", | ||
], | ||
"no-debugger": "error", | ||
"no-empty": "error", | ||
"no-eval": "error", | ||
"no-fallthrough": "error", | ||
"no-invalid-this": "off", | ||
"no-new-wrappers": "error", | ||
"no-shadow": "off", | ||
"no-throw-literal": "error", | ||
"no-trailing-spaces": "error", | ||
"no-undef-init": "off", | ||
"no-underscore-dangle": "error", | ||
"no-unsafe-finally": "error", | ||
"no-unused-labels": "error", | ||
"no-var": "error", | ||
"object-shorthand": "error", | ||
"one-var": "off", | ||
"prefer-arrow/prefer-arrow-functions": "error", | ||
"prefer-const": "error", | ||
"radix": "off", | ||
"spaced-comment": "off", | ||
"use-isnan": "off", | ||
"valid-typeof": ["error", { "requireStringLiterals": false }], | ||
"@typescript-eslint/tslint/config": [ | ||
"error", | ||
{ | ||
"rules": { | ||
"whitespace": [ | ||
true, | ||
"check-branch", | ||
"check-preblock", | ||
"check-decl", | ||
"check-type", | ||
"check-typecast", | ||
"check-module" | ||
] | ||
} | ||
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"] | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["*.ts", "*.tsx"], | ||
extends: [ | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking" | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: "tsconfig.json", | ||
sourceType: "module" | ||
}, | ||
plugins: [ | ||
"eslint-plugin-import", | ||
"eslint-plugin-jsdoc", | ||
"eslint-plugin-prefer-arrow" | ||
], | ||
rules: { | ||
"@typescript-eslint/adjacent-overload-signatures": "off", | ||
"@typescript-eslint/array-type": [ | ||
"error", | ||
{ | ||
default: "array" | ||
} | ||
], | ||
"@typescript-eslint/ban-types": [ | ||
"error", | ||
{ | ||
types: { | ||
Object: { | ||
message: | ||
"Avoid using the `Object` type. Did you mean `object`?" | ||
}, | ||
Function: { | ||
message: | ||
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`." | ||
}, | ||
Boolean: { | ||
message: | ||
"Avoid using the `Boolean` type. Did you mean `boolean`?" | ||
}, | ||
Number: { | ||
message: | ||
"Avoid using the `Number` type. Did you mean `number`?" | ||
}, | ||
String: { | ||
message: | ||
"Avoid using the `String` type. Did you mean `string`?" | ||
}, | ||
Symbol: { | ||
message: | ||
"Avoid using the `Symbol` type. Did you mean `symbol`?" | ||
} | ||
} | ||
} | ||
], | ||
"@typescript-eslint/consistent-type-assertions": "error", | ||
"@typescript-eslint/dot-notation": "off", | ||
"@typescript-eslint/explicit-function-return-type": "error", | ||
"@typescript-eslint/indent": ["error", "tab"], | ||
"@typescript-eslint/member-ordering": "off", | ||
"@typescript-eslint/naming-convention": [ | ||
"error", | ||
{ | ||
selector: "variable", | ||
format: ["camelCase", "UPPER_CASE", "snake_case"], | ||
leadingUnderscore: "allow", | ||
trailingUnderscore: "forbid" | ||
}, | ||
{ | ||
selector: "function", | ||
format: ["camelCase"], | ||
leadingUnderscore: "allow", | ||
trailingUnderscore: "forbid" | ||
}, | ||
{ | ||
selector: "typeLike", | ||
format: ["PascalCase"] | ||
}, | ||
{ | ||
selector: "enumMember", | ||
format: ["UPPER_CASE"] | ||
} | ||
], | ||
"@typescript-eslint/no-empty-function": "error", | ||
"@typescript-eslint/no-empty-interface": "error", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-misused-new": "error", | ||
"@typescript-eslint/no-namespace": "off", | ||
"@typescript-eslint/no-parameter-properties": "off", | ||
"@typescript-eslint/no-unused-expressions": "error", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/no-var-requires": "error", | ||
"@typescript-eslint/prefer-for-of": "error", | ||
"@typescript-eslint/prefer-function-type": "off", | ||
"@typescript-eslint/prefer-namespace-keyword": "off", | ||
"@typescript-eslint/require-await": "warn", | ||
"@typescript-eslint/no-unsafe-assignment": "warn", | ||
"@typescript-eslint/no-unsafe-member-access": "warn", | ||
"@typescript-eslint/restrict-template-expressions": "warn", | ||
"@typescript-eslint/triple-slash-reference": [ | ||
"error", | ||
{ | ||
path: "always", | ||
types: "prefer-import", | ||
lib: "always" | ||
} | ||
], | ||
"@typescript-eslint/unified-signatures": "error", | ||
"@typescript-eslint/no-shadow": [ | ||
"error", | ||
{ | ||
hoist: "all" | ||
} | ||
], | ||
complexity: "off", | ||
"constructor-super": "error", | ||
eqeqeq: ["error", "smart"], | ||
"guard-for-in": "off", | ||
"id-denylist": [ | ||
"error", | ||
"any", | ||
"Number", | ||
"number", | ||
"String", | ||
"string", | ||
"Boolean", | ||
"boolean", | ||
"Undefined", | ||
"undefined" | ||
], | ||
"id-match": "off", | ||
"import/order": "off", | ||
"jsdoc/check-alignment": "error", | ||
"jsdoc/check-indentation": "error", | ||
"jsdoc/newline-after-description": "error", | ||
"max-classes-per-file": ["error", 1], | ||
"no-bitwise": "error", | ||
"no-caller": "error", | ||
"no-cond-assign": "error", | ||
"no-console": [ | ||
"error", | ||
{ | ||
allow: [ | ||
"warn", | ||
"dir", | ||
"time", | ||
"timeEnd", | ||
"timeLog", | ||
"trace", | ||
"assert", | ||
"clear", | ||
"count", | ||
"countReset", | ||
"group", | ||
"groupEnd", | ||
"table", | ||
"dirxml", | ||
"error", | ||
"groupCollapsed", | ||
"Console", | ||
"profile", | ||
"profileEnd", | ||
"timeStamp", | ||
"context" | ||
] | ||
} | ||
], | ||
"no-debugger": "error", | ||
"no-empty": "error", | ||
"no-eval": "error", | ||
"no-fallthrough": "error", | ||
"no-invalid-this": "off", | ||
"no-new-wrappers": "error", | ||
"no-shadow": "off", | ||
"no-throw-literal": "error", | ||
"no-undef-init": "off", | ||
"no-unsafe-finally": "error", | ||
"no-unused-labels": "error", | ||
"no-var": "error", | ||
"object-shorthand": "error", | ||
"one-var": "off", | ||
"prefer-arrow/prefer-arrow-functions": "error", | ||
"prefer-const": "error", | ||
radix: "off", | ||
"spaced-comment": "off", | ||
"use-isnan": "off", | ||
"valid-typeof": ["error", { requireStringLiterals: false }], | ||
} | ||
] | ||
}}] | ||
} | ||
} | ||
] | ||
}; |
{ | ||
"rules": { | ||
"max-nesting-depth": 4, | ||
"indentation": "tab", | ||
"color-hex-length": "long", | ||
"color-no-invalid-hex": true, | ||
"number-leading-zero": "always", | ||
"function-parentheses-space-inside": "never", | ||
"shorthand-property-no-redundant-values": true, | ||
"rule-empty-line-before": "always", | ||
"block-opening-brace-newline-after": "always", | ||
"block-closing-brace-newline-after": "always", | ||
"no-missing-end-of-source-newline": true, | ||
"color-hex-case": "upper", | ||
"selector-list-comma-newline-after" : "always", | ||
"no-duplicate-at-import-rules" : true, | ||
"comment-no-empty" : true | ||
"comment-no-empty": true, | ||
"indentation": "tab", | ||
"max-nesting-depth": 4, | ||
"no-duplicate-at-import-rules": true, | ||
"shorthand-property-no-redundant-values": true | ||
} | ||
} |
{ | ||
"name": "@studyportals/code-style", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0", | ||
"description": "Default linting configurations for the Studyportals repositories", | ||
"main": ".eslintrc.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "npx eslint ./" | ||
}, | ||
@@ -28,14 +28,14 @@ "repository": { | ||
"homepage": "https://github.com/studyportals/CodeStyle#readme", | ||
"peerDependencies": { | ||
"eslint": "7.32.0", | ||
"tslint": "6.1.3" | ||
"dependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.15.0", | ||
"@typescript-eslint/parser": "^5.15.0", | ||
"eslint": "^8.11.0", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-jsdoc": "^39.3.3", | ||
"eslint-plugin-prefer-arrow": "^1.2.3", | ||
"typescript": "^4.6.2" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.12.0", | ||
"@typescript-eslint/parser": "^5.12.0", | ||
"@typescript-eslint/eslint-plugin-tslint": "^5.12.0", | ||
"eslint-plugin-jsdoc": "^37.9.4", | ||
"eslint-plugin-prefer-arrow": "^1.2.3", | ||
"typescript": "^4.5.5" | ||
"engines": { | ||
"node": ">=4.9.1 <19.0.0" | ||
} | ||
} |
194
README.md
# CodeStyle | ||
The purpose of this repository is to provide standardized configuration files for the most common linters we use in Studyportals repositories. The main usage is in [Super-Linter](https://github.com/studyportals/Super-Linter), which uses these configuration files to run the most important linters on most of our repositories. | ||
Please send pull requests to Stefan Klokgieters or Rob van den Hout if you think you want to suggest changes. | ||
Please send pull requests to [@stefanklokgieters](https://github.com/stefanklokgieters) if you think you want to suggest changes. Never publish changes on NPM without a approval... | ||
## Table of Contents | ||
- [Install](#install) | ||
@@ -16,3 +18,5 @@ - [Linters](#linters) | ||
- [Best Practices](#best-practices) | ||
## Install | ||
You can add CodeStyle as a dependency to your project by running the following command: | ||
@@ -25,5 +29,7 @@ | ||
## Linters | ||
### ESLint | ||
[ESLint](https://eslint.org/) is a linter for JavaScript, as well as TypeScript code. It can help find and fix potential problems in your code. | ||
When you install the CodeStyle package you can simply *extend* from the ESLint configuration file inside it. | ||
When you install the CodeStyle package you can simply _extend_ from the ESLint configuration file inside it. | ||
@@ -39,40 +45,86 @@ ```json | ||
``` | ||
#### Global variables | ||
When global variables are used in different files than they we're defined in, ESLint will see it as an undefined variable. To solve this problem, you can define the global variables at the top of your file like so: | ||
```javascript | ||
/* global var1, var2, var3 */ | ||
``` | ||
To avoid this you can define your project's global variables in a custom configuration. | ||
### TSLint | ||
*deprecated* - ESLint can now be used instead | ||
To avoid this you can define your project's global variables in a custom configuration. | ||
[TSLint](https://palantir.github.io/tslint/) is a linter that is specifically meant to lint TypeScript code. When you install the CodeStyle package you can simply *extend* from the TSLint configuration file inside it. | ||
#### Examples | ||
##### Overriding Rules | ||
The example below demonstrates how you can override an existing rule in your `.eslintrc.js`. | ||
```javascript | ||
module.exports = { | ||
extends: "./node_modules/@studyportals/code-style/.eslintrc.js", | ||
rules: { | ||
"@typescript-eslint/array-type": [ | ||
"error", | ||
{ | ||
default: "generic", | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
You can read more about overriding rules [here](https://eslint.org/docs/latest/use/configure/configuration-files#extending-configuration-files). | ||
##### Ignoring Files | ||
The example below demonstrates how you can ignore files in your `.eslintrc.js`. | ||
```javascript | ||
module.exports = { | ||
extends: "./node_modules/@studyportals/code-style/.eslintrc.js", | ||
ignorePatterns: ["**/tests/"], | ||
}; | ||
``` | ||
Otherwise, you can ignore these files by appending them to your `.eslintignore`. You can read more about ignoring files [here](https://eslint.org/docs/latest/use/configure/ignore). | ||
### StyleLint | ||
[StyleLint](https://stylelint.io/) is our main linter for all styling related files. It can read all types of style related syntax, like SCSS, Sass, Less and SugarSS. When you install the CodeStyle package you can simply _extend_ from the StyleLint configuration file inside it. | ||
```json | ||
// tslint.json | ||
// .stylelintrc.json | ||
{ | ||
"extends": "./node_modules/@studyportals/code-style/tslint.json" | ||
"extends": "./node_modules/@studyportals/code-style/.stylelintrc.json" | ||
} | ||
``` | ||
### StyleLint | ||
[StyleLint](https://stylelint.io/) is our main linter for all styling related files. It can read all types of style related syntax, like SCSS, Sass, Less and SugarSS. When you install the CodeStyle package you can simply *extend* from the StyleLint configuration file inside it. | ||
#### Examples | ||
##### Overriding Rules | ||
The example below demonstrates how you can override an existing rule in your `.stylelintrc.json`. | ||
```json | ||
// .stylelintrc.json | ||
{ | ||
"extends": "./node_modules/@studyportals/code-style/.stylelintrc.json" | ||
"extends": "./node_modules/@studyportals/code-style/.stylelintrc.json", | ||
"rule-empty-line-before": [ | ||
"always", | ||
{ | ||
"except": "first-nested" | ||
} | ||
] | ||
} | ||
``` | ||
### SCSSLint | ||
*deprecated* | ||
##### Ignoring Files | ||
[SCSSLint](https://github.com/sds/scss-lint) is a linter specifically meant for running against rulesets that are specific to `.scss` files. Generally though, we prefer to use [StyleLint](#stylelint) since it supports SCSS natively. When you install the CodeStyle package you can simply reference the SCSSLint configuration file inside it from your custom configuration. | ||
The example below demonstrates how you can ignore files in your `.stylelintrc.json`. However, StyleLint recommends you do so with a `.stylelintignore`, instead. You can read more about this [here](https://stylelint.io/user-guide/configure/#ignorefiles). | ||
```yaml | ||
# .scss-lint.yml | ||
options: | ||
config-file: ./node_modules/@studyportals/code-style/.scss-lint.yml | ||
```json | ||
{ | ||
"extends": "./node_modules/@studyportals/code-style/.stylelintrc.json", | ||
"ignoreFiles": ["node_modules/", "**/*.js"] | ||
} | ||
``` | ||
@@ -85,6 +137,34 @@ | ||
```bash | ||
phpcs-run --standard=./node_modules/@studyportals/code-style/phpcodesniffer.xml ./ | ||
phpcs-run --standard=./node_modules/@studyportals/code-style/phpcs.xml ./ | ||
``` | ||
#### Examples | ||
##### Overriding Rules | ||
The example below demonstrates how you can override an existing rule in your `phpcs.xml` to exclude it. | ||
```xml | ||
<?xml version="1.0"?> | ||
<ruleset name="Custom"> | ||
<rule ref="./node_modules/@studyportals/code-style/phpcs.xml"> | ||
<exclude name="Generic.Files.LineEndings"/> | ||
<rule/> | ||
</ruleset> | ||
``` | ||
##### Ignoring Files | ||
The example below demonstrates how you can ignore files in your `phpcs.xml` | ||
```xml | ||
<?xml version="1.0"?> | ||
<ruleset name="Custom"> | ||
<rule ref="./node_modules/@studyportals/code-style/phpcs.xml" /> | ||
<exclude-pattern>tests/**/*.php</exclude-pattern> | ||
</ruleset> | ||
``` | ||
### PHPMD | ||
[PHPMD](https://phpmd.org/) (or PHP Mess Detector) is a linter for PHP files. It takes a given PHP source code base and look for several potential problems within that source. When you install the CodeStyle package you can reference the PHPMD configuration file inside it. | ||
@@ -97,5 +177,77 @@ | ||
#### Examples | ||
##### Overriding Rules | ||
The example below demonstrates how you can override an existing rule in your `phpmd.xml` to exclude it. | ||
```xml | ||
<?xml version="1.0"?> | ||
<ruleset name="Custom"> | ||
<rule ref="./node_modules/@studyportals/code-style/phpcs.xml"> | ||
<exclude name="Generic.Files.LineEndings"/> | ||
<rule/> | ||
</ruleset> | ||
``` | ||
##### Ignoring Files | ||
The example below demonstrates how you can ignore files in your `phpmd.xml` | ||
```xml | ||
<?xml version="1.0"?> | ||
<ruleset name="Custom"> | ||
<rule ref="./node_modules/@studyportals/code-style/phpmd.xml" /> | ||
<exclude-pattern>tests/**/*.php</exclude-pattern> | ||
</ruleset> | ||
``` | ||
### PHPStan | ||
[PHP Static Analysis Tool](https://github.com/squizlabs/PHP_CodeSniffer) is a linter for PHP files. It can discover bugs in the code without running it!. PHPStan can be run from the command line, where the configuration can be referenced. | ||
phpstan.neon configuration from the code style can be included as follows: | ||
```yaml | ||
includes: | ||
- ./node_modules/@studyportals/code-style/phpstan.neon | ||
``` | ||
Command to run the phpstan | ||
```bash | ||
phpstan analyse -c phpstan.neon | ||
``` | ||
##### Overriding Rules | ||
The example below demonstrates how you can override an existing rule in your `phpstan.neon`. | ||
```yaml | ||
includes: | ||
- ./node_modules/@studyportals/code-style/phpstan.neon | ||
- phpstan-baseline.neon | ||
parameters: | ||
level: 8 | ||
``` | ||
##### Ignoring Files | ||
The example below demonstrates how you can ignore files in your `phpstan.xml` | ||
```yaml | ||
includes: | ||
- ./node_modules/@studyportals/code-style/phpstan.neon | ||
- phpstan-baseline.neon | ||
parameters: | ||
excludePaths: | ||
- Modules/RankingXDiscipline/ChartBase/rankings_disciplines.php | ||
- TestSuites\PHPUnit\Integration\Router\Handlers\Error\DebugErrorHandlerTest.php | ||
- TestSuites\PHPUnit\Integration\Router\Handlers\Error\DebugXhrErrorHandlerTest.php | ||
- TestSuites\PHPUnit\Integration\Router\IndexTest.php | ||
``` | ||
## Best practices | ||
### Whitelisting | ||
Whitelisting source folders is the recommended way of specifying which files should be linted in a project. If certain file within the source folders needs to be skipped, that should be done on file level. | ||
Whitelisting source folders is the recommended way of specifying which files should be linted in a project. If certain file within the source folders needs to be skipped, that should be done on file level. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
1
249
20096
7
11
274
2
+ Addedeslint@^8.11.0
+ Addedeslint-plugin-import@^2.25.4
+ Addedeslint-plugin-jsdoc@^39.3.3
+ Addedtypescript@^4.6.2
+ Added@es-joy/jsdoccomment@0.36.1(transitive)
+ Added@eslint-community/eslint-utils@4.4.1(transitive)
+ Added@eslint-community/regexpp@4.12.1(transitive)
+ Added@eslint/eslintrc@2.1.4(transitive)
+ Added@eslint/js@8.57.1(transitive)
+ Added@humanwhocodes/config-array@0.13.0(transitive)
+ Added@humanwhocodes/module-importer@1.0.1(transitive)
+ Added@humanwhocodes/object-schema@2.0.3(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@rtsao/scc@1.1.0(transitive)
+ Added@types/json-schema@7.0.15(transitive)
+ Added@types/json5@0.0.29(transitive)
+ Added@types/semver@7.5.8(transitive)
+ Added@typescript-eslint/eslint-plugin@5.62.0(transitive)
+ Added@typescript-eslint/parser@5.62.0(transitive)
+ Added@typescript-eslint/scope-manager@5.62.0(transitive)
+ Added@typescript-eslint/type-utils@5.62.0(transitive)
+ Added@typescript-eslint/types@5.62.0(transitive)
+ Added@typescript-eslint/typescript-estree@5.62.0(transitive)
+ Added@typescript-eslint/utils@5.62.0(transitive)
+ Added@typescript-eslint/visitor-keys@5.62.0(transitive)
+ Added@ungap/structured-clone@1.2.1(transitive)
+ Addedacorn@8.14.0(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedarray-buffer-byte-length@1.0.1(transitive)
+ Addedarray-includes@3.1.8(transitive)
+ Addedarray-union@2.1.0(transitive)
+ Addedarray.prototype.findlastindex@1.2.5(transitive)
+ Addedarray.prototype.flat@1.3.2(transitive)
+ Addedarray.prototype.flatmap@1.3.2(transitive)
+ Addedarraybuffer.prototype.slice@1.0.3(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.2(transitive)
+ Addedcomment-parser@1.3.1(transitive)
+ Addeddata-view-buffer@1.0.1(transitive)
+ Addeddata-view-byte-length@1.0.1(transitive)
+ Addeddata-view-byte-offset@1.0.0(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddir-glob@3.0.1(transitive)
+ Addeddoctrine@2.1.0(transitive)
+ Addeddunder-proto@1.0.0(transitive)
+ Addedes-abstract@1.23.5(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedes-set-tostringtag@2.0.3(transitive)
+ Addedes-shim-unscopables@1.0.2(transitive)
+ Addedes-to-primitive@1.3.0(transitive)
+ Addedeslint@8.57.1(transitive)
+ Addedeslint-import-resolver-node@0.3.9(transitive)
+ Addedeslint-module-utils@2.12.0(transitive)
+ Addedeslint-plugin-import@2.31.0(transitive)
+ Addedeslint-plugin-jsdoc@39.9.1(transitive)
+ Addedeslint-plugin-prefer-arrow@1.2.3(transitive)
+ Addedeslint-scope@7.2.2(transitive)
+ Addedeslint-visitor-keys@3.4.3(transitive)
+ Addedespree@9.6.1(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction.prototype.name@1.1.6(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.6(transitive)
+ Addedget-symbol-description@1.0.2(transitive)
+ Addedglob-parent@6.0.2(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedglobby@11.1.0(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedgraphemer@1.4.0(transitive)
+ Addedhas-bigints@1.0.2(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedinternal-slot@1.0.7(transitive)
+ Addedis-array-buffer@3.0.4(transitive)
+ Addedis-async-function@2.0.0(transitive)
+ Addedis-bigint@1.1.0(transitive)
+ Addedis-boolean-object@1.2.0(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-data-view@1.0.1(transitive)
+ Addedis-date-object@1.0.5(transitive)
+ Addedis-finalizationregistry@1.1.0(transitive)
+ Addedis-generator-function@1.0.10(transitive)
+ Addedis-map@2.0.3(transitive)
+ Addedis-negative-zero@2.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-number-object@1.1.0(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedis-regex@1.2.0(transitive)
+ Addedis-set@2.0.3(transitive)
+ Addedis-shared-array-buffer@1.0.3(transitive)
+ Addedis-string@1.1.0(transitive)
+ Addedis-symbol@1.1.0(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedis-weakmap@2.0.2(transitive)
+ Addedis-weakref@1.0.2(transitive)
+ Addedis-weakset@2.0.3(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedjsdoc-type-pratt-parser@3.1.0(transitive)
+ Addedjson5@1.0.2(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedmath-intrinsics@1.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addednatural-compare-lite@1.4.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedobject.fromentries@2.0.8(transitive)
+ Addedobject.groupby@1.0.3(transitive)
+ Addedobject.values@1.2.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpath-type@4.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreflect.getprototypeof@1.0.8(transitive)
+ Addedregexp.prototype.flags@1.5.3(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedsafe-array-concat@1.1.2(transitive)
+ Addedsafe-regex-test@1.0.3(transitive)
+ Addedsemver@6.3.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedslash@3.0.0(transitive)
+ Addedspdx-exceptions@2.5.0(transitive)
+ Addedspdx-expression-parse@3.0.1(transitive)
+ Addedspdx-license-ids@3.0.20(transitive)
+ Addedstring.prototype.trim@1.2.10(transitive)
+ Addedstring.prototype.trimend@1.0.9(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
+ Addedstrip-bom@3.0.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedtsconfig-paths@3.15.0(transitive)
+ Addedtsutils@3.21.0(transitive)
+ Addedtyped-array-buffer@1.0.2(transitive)
+ Addedtyped-array-byte-length@1.0.1(transitive)
+ Addedtyped-array-byte-offset@1.0.3(transitive)
+ Addedtyped-array-length@1.0.7(transitive)
+ Addedtypescript@4.9.5(transitive)
+ Addedunbox-primitive@1.0.2(transitive)
+ Addedwhich-boxed-primitive@1.1.0(transitive)
+ Addedwhich-builtin-type@1.2.0(transitive)
+ Addedwhich-collection@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.16(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removed@babel/code-frame@7.12.11(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/highlight@7.25.9(transitive)
- Removed@eslint/eslintrc@0.4.3(transitive)
- Removed@humanwhocodes/config-array@0.5.0(transitive)
- Removed@humanwhocodes/object-schema@1.2.1(transitive)
- Removedacorn@7.4.1(transitive)
- Removedajv@8.17.1(transitive)
- Removedansi-colors@4.1.3(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedastral-regex@2.0.0(transitive)
- Removedbuiltin-modules@1.1.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcommander@2.20.3(transitive)
- Removeddiff@4.0.2(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedenquirer@2.4.1(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedeslint@7.32.0(transitive)
- Removedeslint-utils@2.1.0(transitive)
- Removedeslint-visitor-keys@1.3.02.1.0(transitive)
- Removedespree@7.3.1(transitive)
- Removedesprima@4.0.1(transitive)
- Removedfast-uri@3.0.3(transitive)
- Removedfunctional-red-black-tree@1.0.1(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedignore@4.0.6(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjson-schema-traverse@1.0.0(transitive)
- Removedlodash.truncate@4.4.2(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedprogress@2.0.3(transitive)
- Removedregexpp@3.2.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedslice-ansi@4.0.0(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtable@6.9.0(transitive)
- Removedtslint@6.1.3(transitive)
- Removedtsutils@2.29.0(transitive)
- Removedtypescript@5.7.2(transitive)
- Removedv8-compile-cache@2.4.0(transitive)