Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): add config all.json #313

Merged
merged 30 commits into from May 15, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b6d7590
feat(eslint-plugin): add config all.json
ldrick Feb 24, 2019
8de8ddc
Merge branch 'master' into provide-all-config
ldrick Feb 25, 2019
3cb4567
fix: no new rules for recommended.json and extract base.json
ldrick Feb 27, 2019
886b765
fix: export base.json and all.json
ldrick Feb 28, 2019
c51d434
fix: path to base.json
ldrick Feb 28, 2019
c0eec0e
fix: regenerate configs with fixed path
ldrick Feb 28, 2019
e9a012c
feat(eslint-plugin): provide index.ts to collect rules
ldrick Mar 2, 2019
fdd01d9
test: add tests for ./src/rules/index.ts and ./src/.configs/all.json
ldrick Mar 2, 2019
507c14a
fix: test for Node.js 6
ldrick Mar 2, 2019
876e70c
fix: remove left overs
ldrick Mar 2, 2019
c951296
Merge branch 'master' into provide-all-config
ldrick Mar 2, 2019
883fa47
test: improve coverage
ldrick Mar 3, 2019
ec021d7
feat(eslint-plugin): disable eslints "no-useless-constructor" rule
ldrick Mar 5, 2019
3d9205a
Merge branch 'master' into provide-all-config
ldrick Mar 7, 2019
863654e
feat(eslint-plugin): add base config to generated configs
ldrick Mar 7, 2019
1ed1044
Merge branch 'master' into provide-all-config
ldrick Mar 10, 2019
f8bc247
Merge branch 'master' into provide-all-config
ldrick Mar 15, 2019
6b7b435
fix: remove recommendation from docs for rules not in config
ldrick Mar 15, 2019
5b65090
chore: merge master
ldrick Mar 21, 2019
673b82e
Merge remote-tracking branch 'upstream/master' into provide-all-config
ldrick Apr 26, 2019
66944f8
feat(eslint-plugin): set rules in all.json to 'error'
ldrick Apr 26, 2019
d91badc
Merge branch 'master' into provide-all-config
ldrick Apr 30, 2019
8a947ea
Merge remote-tracking branch 'upstream/master' into provide-all-config
ldrick May 3, 2019
b5cb999
Merge remote-tracking branch 'upstream/master' into provide-all-config
ldrick May 6, 2019
4f28f41
Merge remote-tracking branch 'upstream/master' into provide-all-config
ldrick May 10, 2019
83562a8
fix: for manual provided config
ldrick May 10, 2019
0c01c4a
Merge remote-tracking branch 'upstream/master' into provide-all-config
ldrick May 13, 2019
846c74b
fix: remove of unbound-method as recommended in docs again
ldrick May 13, 2019
aea2fd6
Merge remote-tracking branch 'upstream/master' into provide-all-config
ldrick May 13, 2019
ca6eb21
fix: all reviewed things and added deprecated filter
ldrick May 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .prettierignore
Expand Up @@ -3,7 +3,6 @@
**/coverage
**/shared-fixtures
**/tests/integration/fixtures/**/*
**/lib/configs/recommended.json
**/.vscode
**/.nyc_output
packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js
8 changes: 4 additions & 4 deletions packages/eslint-plugin/README.md
Expand Up @@ -113,7 +113,7 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e
| [`@typescript-eslint/adjacent-overload-signatures`](./docs/rules/adjacent-overload-signatures.md) | Require that member overloads be consecutive (`adjacent-overload-signatures` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/array-type`](./docs/rules/array-type.md) | Requires using either `T[]` or `Array<T>` for arrays (`array-type` from TSLint) | :heavy_check_mark: | :wrench: |
| [`@typescript-eslint/ban-types`](./docs/rules/ban-types.md) | Enforces that types will not to be used (`ban-types` from TSLint) | :heavy_check_mark: | :wrench: |
| [`@typescript-eslint/ban-ts-ignore`](./docs/rules/ban-ts-ignore.md) | Bans “// @ts-ignore” comments from being used (`ban-ts-ignore` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/ban-ts-ignore`](./docs/rules/ban-ts-ignore.md) | Bans “// @ts-ignore” comments from being used (`ban-ts-ignore` from TSLint) | | |
| [`@typescript-eslint/camelcase`](./docs/rules/camelcase.md) | Enforce camelCase naming convention | :heavy_check_mark: | |
| [`@typescript-eslint/class-name-casing`](./docs/rules/class-name-casing.md) | Require PascalCased class and interface names (`class-name` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/explicit-function-return-type`](./docs/rules/explicit-function-return-type.md) | Require explicit return types on functions and class methods | :heavy_check_mark: | |
Expand All @@ -136,7 +136,7 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e
| [`@typescript-eslint/no-non-null-assertion`](./docs/rules/no-non-null-assertion.md) | Disallows non-null assertions using the `!` postfix operator (`no-non-null-assertion` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/no-object-literal-type-assertion`](./docs/rules/no-object-literal-type-assertion.md) | Forbids an object literal to appear in a type assertion expression (`no-object-literal-type-assertion` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/no-parameter-properties`](./docs/rules/no-parameter-properties.md) | Disallow the use of parameter properties in class constructors. (`no-parameter-properties` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` (`no-require-imports` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/no-require-imports`](./docs/rules/no-require-imports.md) | Disallows invocation of `require()` (`no-require-imports` from TSLint) | | |
| [`@typescript-eslint/no-this-alias`](./docs/rules/no-this-alias.md) | Disallow aliasing `this` (`no-this-assignment` from TSLint) | | |
| [`@typescript-eslint/no-triple-slash-reference`](./docs/rules/no-triple-slash-reference.md) | Disallow `/// <reference path="" />` comments (`no-reference` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/no-type-alias`](./docs/rules/no-type-alias.md) | Disallow the use of type aliases (`interface-over-type-literal` from TSLint) | | |
Expand All @@ -146,10 +146,10 @@ Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.e
| [`@typescript-eslint/no-use-before-define`](./docs/rules/no-use-before-define.md) | Disallow the use of variables before they are defined | :heavy_check_mark: | |
| [`@typescript-eslint/no-useless-constructor`](./docs/rules/no-useless-constructor.md) | Disallow unnecessary constructors | | |
| [`@typescript-eslint/no-var-requires`](./docs/rules/no-var-requires.md) | Disallows the use of require statements except in import statements (`no-var-requires` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Use function types instead of interfaces with call signatures (`callable-types` from TSLint) | | :wrench: |
| [`@typescript-eslint/prefer-function-type`](./docs/rules/prefer-function-type.md) | Use function types instead of interfaces with call signatures (`callable-types` from TSLint) | | :wrench: |
| [`@typescript-eslint/prefer-interface`](./docs/rules/prefer-interface.md) | Prefer an interface declaration over a type literal (type T = { ... }) (`interface-over-type-literal` from TSLint) | :heavy_check_mark: | :wrench: |
| [`@typescript-eslint/prefer-namespace-keyword`](./docs/rules/prefer-namespace-keyword.md) | Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (`no-internal-module` from TSLint) | :heavy_check_mark: | :wrench: |
| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async. (`promise-function-async` from TSLint) | :heavy_check_mark: | |
| [`@typescript-eslint/promise-function-async`](./docs/rules/promise-function-async.md) | Requires any function or method that returns a Promise to be marked async. (`promise-function-async` from TSLint) | | |
| [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string. (`restrict-plus-operands` from TSLint) | | |
| [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations (`typedef-whitespace` from TSLint) | :heavy_check_mark: | :wrench: |
| [`@typescript-eslint/unified-signatures`](./docs/rules/unified-signatures.md) | Warns for any two overloads that could be unified into one. (`unified-signatures` from TSLint) | | |
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin/package.json
Expand Up @@ -28,7 +28,7 @@
"docs": "eslint-docs",
"docs:check": "eslint-docs check",
"test": "jest --coverage",
"recommended:update": "ts-node tools/update-recommended.ts",
"generate:configs": "ts-node --files tools/generate-configs.ts",
"prebuild": "npm run clean",
"build": "tsc -p tsconfig.build.json",
"clean": "rimraf dist/",
Expand All @@ -37,7 +37,6 @@
"dependencies": {
"@typescript-eslint/parser": "1.5.0",
"@typescript-eslint/typescript-estree": "1.5.0",
"requireindex": "^1.2.0",
"tsutils": "^3.7.0"
},
"devDependencies": {
Expand Down
49 changes: 49 additions & 0 deletions packages/eslint-plugin/src/configs/all.json
@@ -0,0 +1,49 @@
{
"extends": "./configs/base.json",
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-ts-ignore": "warn",
ldrick marked this conversation as resolved.
Show resolved Hide resolved
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/generic-type-naming": "warn",
"@typescript-eslint/indent": "error",
"@typescript-eslint/interface-name-prefix": "error",
"@typescript-eslint/member-delimiter-style": "error",
"@typescript-eslint/member-naming": "warn",
"@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/no-angle-bracket-type-assertion": "error",
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-extraneous-class": "warn",
"@typescript-eslint/no-for-in-array": "warn",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-object-literal-type-assertion": "error",
"@typescript-eslint/no-parameter-properties": "error",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-triple-slash-reference": "error",
"@typescript-eslint/no-type-alias": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-useless-constructor": "warn",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-interface": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/promise-function-async": "warn",
"@typescript-eslint/require-array-sort-compare": "warn",
"@typescript-eslint/restrict-plus-operands": "warn",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "warn"
}
}
14 changes: 14 additions & 0 deletions packages/eslint-plugin/src/configs/base.json
@@ -0,0 +1,14 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"camelcase": "off",
ldrick marked this conversation as resolved.
Show resolved Hide resolved
"indent": "off",
"no-array-constructor": "off",
"no-unused-vars": "off",
"no-useless-constructor": "off"
}
}
10 changes: 1 addition & 9 deletions packages/eslint-plugin/src/configs/recommended.json
@@ -1,24 +1,17 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"extends": "./configs/base.json",
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-types": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/explicit-member-accessibility": "error",
"indent": "off",
"@typescript-eslint/indent": "error",
"@typescript-eslint/interface-name-prefix": "error",
"@typescript-eslint/member-delimiter-style": "error",
"@typescript-eslint/no-angle-bracket-type-assertion": "error",
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "warn",
Expand All @@ -29,7 +22,6 @@
"@typescript-eslint/no-object-literal-type-assertion": "error",
"@typescript-eslint/no-parameter-properties": "error",
"@typescript-eslint/no-triple-slash-reference": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-var-requires": "error",
Expand Down
20 changes: 6 additions & 14 deletions packages/eslint-plugin/src/index.ts
@@ -1,22 +1,14 @@
import requireIndex from 'requireindex';
import path from 'path';
import rules from './rules';

import all from './configs/all.json';
import base from './configs/base.json';
import recommended from './configs/recommended.json';

const rules = requireIndex(path.join(__dirname, 'rules'));
// eslint expects the rule to be on rules[name], not rules[name].default
const rulesWithoutDefault = Object.keys(rules).reduce<Record<string, any>>(
(acc, ruleName) => {
acc[ruleName] = rules[ruleName].default;
return acc;
},
{},
);

// import all rules in lib/rules
export = {
rules: rulesWithoutDefault,
rules,
configs: {
all,
base,
recommended,
},
};
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/ban-ts-ignore.ts
Expand Up @@ -8,7 +8,7 @@ export default util.createRule({
description: 'Bans “// @ts-ignore” comments from being used.',
tslintRuleName: 'ban-ts-ignore',
category: 'Best Practices',
recommended: 'error',
recommended: false,
},
schema: [],
messages: {
Expand Down
91 changes: 91 additions & 0 deletions packages/eslint-plugin/src/rules/index.ts
@@ -0,0 +1,91 @@
import adjacentOverloadSignatures from './adjacent-overload-signatures';
import arrayType from './array-type';
import banTsIgnore from './ban-ts-ignore';
import banTypes from './ban-types';
import camelcase from './camelcase';
import classNameCasing from './class-name-casing';
import explicitFunctionReturnType from './explicit-function-return-type';
import explicitMemberAccessibility from './explicit-member-accessibility';
import genericTypeNaming from './generic-type-naming';
import indent from './indent';
import interfaceNamePrefix from './interface-name-prefix';
import memberDelimiterStyle from './member-delimiter-style';
import memberNaming from './member-naming';
import memberOrdering from './member-ordering';
import noAngleBracketTypeAssertion from './no-angle-bracket-type-assertion';
import noArrayConstructor from './no-array-constructor';
import noEmptyInterface from './no-empty-interface';
import noExplicitAny from './no-explicit-any';
import noExtraneousClass from './no-extraneous-class';
import noForInArray from './no-for-in-array';
import noInferrableTypes from './no-inferrable-types';
import noMisusedNew from './no-misused-new';
import noNamespace from './no-namespace';
import noNonNullAssertion from './no-non-null-assertion';
import noObjectLiteralTypeAssertion from './no-object-literal-type-assertion';
import noParameterProperties from './no-parameter-properties';
import noRequireImports from './no-require-imports';
import noThisAlias from './no-this-alias';
import noTripleSlashReference from './no-triple-slash-reference';
import noTypeAlias from './no-type-alias';
import noUnnecessaryQualifier from './no-unnecessary-qualifier';
import noUnnecessaryTypeAssertion from './no-unnecessary-type-assertion';
import noUnusedVars from './no-unused-vars';
import noUseBeforeDefine from './no-use-before-define';
import noUselessConstructor from './no-useless-constructor';
import noVarRequires from './no-var-requires';
import preferFunctionType from './prefer-function-type';
import preferInterface from './prefer-interface';
import preferNamespaceKeyword from './prefer-namespace-keyword';
import promiseFunctionAsync from './promise-function-async';
import requireArraySortCompare from './require-array-sort-compare';
import restrictPlusOperands from './restrict-plus-operands';
import typeAnnotationSpacing from './type-annotation-spacing';
import unifiedSignatures from './unified-signatures';

export default {
'adjacent-overload-signatures': adjacentOverloadSignatures,
'array-type': arrayType,
'ban-ts-ignore': banTsIgnore,
'ban-types': banTypes,
camelcase: camelcase,
'class-name-casing': classNameCasing,
'explicit-function-return-type': explicitFunctionReturnType,
'explicit-member-accessibility': explicitMemberAccessibility,
'generic-type-naming': genericTypeNaming,
indent: indent,
'interface-name-prefix': interfaceNamePrefix,
'member-delimiter-style': memberDelimiterStyle,
'member-naming': memberNaming,
'member-ordering': memberOrdering,
'no-angle-bracket-type-assertion': noAngleBracketTypeAssertion,
'no-array-constructor': noArrayConstructor,
'no-empty-interface': noEmptyInterface,
'no-explicit-any': noExplicitAny,
'no-extraneous-class': noExtraneousClass,
'no-for-in-array': noForInArray,
'no-inferrable-types': noInferrableTypes,
'no-misused-new': noMisusedNew,
'no-namespace': noNamespace,
'no-non-null-assertion': noNonNullAssertion,
'no-object-literal-type-assertion': noObjectLiteralTypeAssertion,
'no-parameter-properties': noParameterProperties,
'no-require-imports': noRequireImports,
'no-this-alias': noThisAlias,
'no-triple-slash-reference': noTripleSlashReference,
'no-type-alias': noTypeAlias,
'no-unnecessary-qualifier': noUnnecessaryQualifier,
'no-unnecessary-type-assertion': noUnnecessaryTypeAssertion,
'no-unused-vars': noUnusedVars,
'no-use-before-define': noUseBeforeDefine,
'no-useless-constructor': noUselessConstructor,
'no-var-requires': noVarRequires,
'prefer-function-type': preferFunctionType,
'prefer-interface': preferInterface,
'prefer-namespace-keyword': preferNamespaceKeyword,
'promise-function-async': promiseFunctionAsync,
'require-array-sort-compare': requireArraySortCompare,
'restrict-plus-operands': restrictPlusOperands,
'type-annotation-spacing': typeAnnotationSpacing,
'unified-signatures': unifiedSignatures,
};
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/no-require-imports.ts
Expand Up @@ -9,7 +9,7 @@ export default util.createRule({
description: 'Disallows invocation of `require()`.',
tslintName: 'no-require-imports',
category: 'Best Practices',
recommended: 'error',
recommended: false,
},
schema: [],
messages: {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/promise-function-async.ts
Expand Up @@ -21,7 +21,7 @@ export default util.createRule<Options, MessageIds>({
'Requires any function or method that returns a Promise to be marked async.',
tslintName: 'promise-function-async',
category: 'Best Practices',
recommended: 'error',
recommended: false,
},
messages: {
missingAsync: 'Functions that return promises must be async.',
Expand Down