Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin)!: change recommended config#729

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JamesHenry merged 22 commits intomasterfromv2-update-recommended
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
22 commits
Select commitHold shift + click to select a range
07a59d8
feat(eslint-plugin): change recommended config
bradzacherJul 20, 2019
659115d
feat: disable base rules, prettier generated configs
bradzacherJul 21, 2019
8d3cb2a
Merge branch 'master' into v2-update-recommended
bradzacherJul 21, 2019
9b39860
Merge branch 'master' into v2-update-recommended
bradzacherJul 25, 2019
52c1699
Merge branch 'master' into v2-update-recommended
bradzacherJul 25, 2019
42d62f7
fix: lint errors
bradzacherJul 25, 2019
df4b45c
Merge branch 'master' into v2-update-recommended
bradzacherJul 25, 2019
d1ec431
Merge branch 'master' into v2-update-recommended
bradzacherJul 28, 2019
c9ca0fe
chore: fix lint errors
bradzacherJul 28, 2019
20761bb
Merge branch 'master' into v2-update-recommended
bradzacherJul 29, 2019
22d2db7
chore: update yarn.lock
bradzacherJul 29, 2019
ce7ecf1
Merge branch 'master' into v2-update-recommended
bradzacherJul 29, 2019
a03c88f
feat: change defaults of no-this-alias
bradzacherJul 29, 2019
bf4ae8a
fix: add generation for rules added in #595
bradzacherJul 29, 2019
c3aef68
fix: fix the test because I'm a dummy
bradzacherJul 30, 2019
953d20d
Merge branch 'master' into v2-update-recommended
bradzacherJul 30, 2019
a031e18
chore: review fixes
bradzacherJul 31, 2019
0c0cbc3
Merge branch 'master' into v2-update-recommended
bradzacherAug 2, 2019
81b9d43
fix: correct defaults for no-inferrable-types
bradzacherAug 8, 2019
a0404b8
docs: update no-inferrable-types docs
bradzacherAug 8, 2019
aa1193e
fix: lint
bradzacherAug 8, 2019
d56558b
Merge branch 'master' into v2-update-recommended
JamesHenryAug 13, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions.eslintrc.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,23 +21,12 @@ module.exports = {
// our plugin :D
//

'@typescript-eslint/ban-ts-ignore': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/unbound-method': 'off',

//
// eslint base
Expand DownExpand Up@@ -110,12 +99,12 @@ module.exports = {
'import/no-mutable-exports': 'error',
// Prevent importing the default as if it were named
'import/no-named-default': 'error',
// Prohibit named exports // we want everything to be a named export
'import/no-named-export': 'off',
// Prohibit named exports
'import/no-named-export': 'off', // we want everything to be a named export
// Forbid a module from importing itself
'import/no-self-import': 'error',
// Require modules with a single export to use a default export // we want everything to be named
'import/prefer-default-export': 'off',
// Require modules with a single export to use a default export
'import/prefer-default-export': 'off', // we want everything to be named
},
parserOptions: {
sourceType: 'module',
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletionspackages/eslint-plugin-tslint/src/custom-linter.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import { ILinterOptions, Linter, LintResult } from 'tslint';
import { Program } from 'typescript';
import { Program, SourceFile } from 'typescript';

// We need to access the program, but Linter has private program already
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All@@ -14,7 +14,7 @@ export class CustomLinter extends TSLintLinter {
return super.getResult();
}

getSourceFile(fileName: string) {
getSourceFile(fileName: string): SourceFile | undefined {
return this.program.getSourceFile(fileName);
}
}
38 changes: 19 additions & 19 deletionspackages/eslint-plugin/README.md
View file
Open in desktop

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletionspackages/eslint-plugin/docs/rules/no-inferrable-types.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,8 +24,8 @@ The default options are:

```JSON
{
"ignoreParameters":true,
"ignoreProperties":true,
"ignoreParameters":false,
"ignoreProperties":false,
}
```

Expand Down
2 changes: 2 additions & 0 deletionspackages/eslint-plugin/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,8 +49,10 @@
"devDependencies": {
"@types/json-schema": "^7.0.3",
"@types/marked": "^0.6.5",
"@types/prettier": "^1.18.0",
"chalk": "^2.4.2",
"marked": "^0.7.0",
"prettier": "*",
"typescript": "*"
},
"peerDependencies": {
Expand Down
2 changes: 2 additions & 0 deletionspackages/eslint-plugin/src/configs/all.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@
"@typescript-eslint/member-ordering": "error",
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "error",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
Expand DownExpand Up@@ -62,6 +63,7 @@
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"require-await": "off",
"@typescript-eslint/require-await": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
Expand Down
8 changes: 2 additions & 6 deletionspackages/eslint-plugin/src/configs/base.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
]
"parserOptions": { "sourceType": "module" },
"plugins": ["@typescript-eslint"]
}
32 changes: 21 additions & 11 deletionspackages/eslint-plugin/src/configs/recommended.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,48 @@
{
"extends": "./configs/base.json",
"rules": {
"no-var": "error",
"prefer-const": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-ignore": "error",
"@typescript-eslint/ban-types": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "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",
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "error",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-parameter-properties": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "warn",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/type-annotation-spacing": "error"
"@typescript-eslint/prefer-regexp-exec": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"require-await": "off",
"@typescript-eslint/require-await": "error",
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
"no-var": "error",
"prefer-const": "error",
"prefer-rest-params": "error",
"prefer-spread": "error"
}
}
7 changes: 4 additions & 3 deletionspackages/eslint-plugin/src/rules/array-type.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,7 +94,8 @@ export default util.createRule<Options, MessageIds>({
docs: {
description: 'Requires using either `T[]` or `Array<T>` for arrays',
category: 'Stylistic Issues',
recommended: 'error',
// too opinionated to be recommended
recommended: false,
},
fixable: 'code',
messages: {
Expand DownExpand Up@@ -168,7 +169,7 @@ export default util.createRule<Options, MessageIds>({
}

return {
TSArrayType(node: TSESTree.TSArrayType) {
TSArrayType(node): void {
if (
isArrayOption ||
(isArraySimpleOption && isSimpleType(node.elementType))
Expand DownExpand Up@@ -241,7 +242,7 @@ export default util.createRule<Options, MessageIds>({
});
},

TSTypeReference(node: TSESTree.TSTypeReference) {
TSTypeReference(node): void {
if (
isGenericOption ||
node.typeName.type !== AST_NODE_TYPES.Identifier
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/await-thenable.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@ export default util.createRule({
docs: {
description: 'Disallows awaiting a value that is not a Thenable',
category: 'Best Practices',
recommended:false,
recommended:'error',
},
messages: {
await: 'Unexpected `await` of a non-Promise (non-"Thenable") value.',
Expand All@@ -24,7 +24,7 @@ export default util.createRule({
const checker = parserServices.program.getTypeChecker();

return {
AwaitExpression(node) {
AwaitExpression(node): void {
const originalNode = parserServices.esTreeNodeToTSNodeMap.get<
ts.AwaitExpression
>(node);
Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/rules/ban-ts-ignore.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ export default util.createRule({
docs: {
description: 'Bans “// @ts-ignore” comments from being used',
category: 'Best Practices',
recommended:false,
recommended:'error',
},
schema: [],
messages: {
Expand Down
5 changes: 3 additions & 2 deletionspackages/eslint-plugin/src/rules/ban-types.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ function stringifyTypeName(

function getCustomMessage(
bannedType: null | string | { message?: string; fixWith?: string },
) {
): string {
if (bannedType === null) {
return '';
}
Expand DownExpand Up@@ -108,7 +108,7 @@ export default util.createRule<Options, MessageIds>({
],
create(context, [{ types: bannedTypes }]) {
return {
TSTypeReference({ typeName }) {
TSTypeReference({ typeName }): void {
const name = stringifyTypeName(typeName, context.getSourceCode());

if (name in bannedTypes) {
Expand All@@ -124,6 +124,7 @@ export default util.createRule<Options, MessageIds>({
name: name,
customMessage,
},
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
fix: fixWith ? fixer => fixer.replaceText(typeName, fixWith) : null,
});
}
Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/rules/camelcase.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -90,7 +90,7 @@ export default util.createRule<Options, MessageIds>({
}

return {
Identifier(node) {
Identifier(node): void {
/*
* Leading and trailing underscores are commonly used to flag
* private/protected identifiers, strip them
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/class-name-casing.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -64,15 +64,15 @@ export default util.createRule({
| TSESTree.ClassDeclaration
| TSESTree.TSInterfaceDeclaration
| TSESTree.ClassExpression,
) {
): void {
// class expressions (i.e. export default class {}) are OK
if (node.id && !isPascalCase(node.id.name)) {
report(node, node.id);
}
},
"VariableDeclarator[init.type='ClassExpression']"(
node: TSESTree.VariableDeclarator,
) {
): void {
if (
node.id.type === AST_NODE_TYPES.ArrayPattern ||
node.id.type === AST_NODE_TYPES.ObjectPattern
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export default util.createRule<Options, MessageIds>({

function reportIncorrectAssertionType(
node: TSESTree.TSTypeAssertion | TSESTree.TSAsExpression,
) {
): void {
const messageId = options.assertionStyle;
context.report({
node,
Expand All@@ -89,7 +89,7 @@ export default util.createRule<Options, MessageIds>({
});
}

function checkType(node: TSESTree.TypeNode) {
function checkType(node: TSESTree.TypeNode): boolean {
switch (node.type) {
case AST_NODE_TYPES.TSAnyKeyword:
case AST_NODE_TYPES.TSUnknownKeyword:
Expand All@@ -107,7 +107,7 @@ export default util.createRule<Options, MessageIds>({

function checkExpression(
node: TSESTree.TSTypeAssertion | TSESTree.TSAsExpression,
) {
): void {
if (
options.assertionStyle === 'never' ||
options.objectLiteralTypeAssertions === 'allow' ||
Expand DownExpand Up@@ -137,15 +137,15 @@ export default util.createRule<Options, MessageIds>({
}

return {
TSTypeAssertion(node) {
TSTypeAssertion(node): void {
if (options.assertionStyle !== 'angle-bracket') {
reportIncorrectAssertionType(node);
return;
}

checkExpression(node);
},
TSAsExpression(node) {
TSAsExpression(node): void {
if (options.assertionStyle !== 'as') {
reportIncorrectAssertionType(node);
return;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ export default util.createRule({
description:
'Consistent with type definition either `interface` or `type`',
category: 'Stylistic Issues',
// too opinionated to be recommended
recommended: false,
},
messages: {
Expand All@@ -29,7 +30,7 @@ export default util.createRule({
return {
"TSTypeAliasDeclaration[typeAnnotation.type='TSTypeLiteral']"(
node: TSESTree.TSTypeAliasDeclaration,
) {
): void {
if (option === 'interface') {
context.report({
node: node.id,
Expand DownExpand Up@@ -63,7 +64,7 @@ export default util.createRule({
});
}
},
TSInterfaceDeclaration(node) {
TSInterfaceDeclaration(node): void {
if (option === 'type') {
context.report({
node: node.id,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,8 +47,8 @@ export default util.createRule<Options, MessageIds>({
defaultOptions: [
{
allowExpressions: false,
allowTypedFunctionExpressions:false,
allowHigherOrderFunctions:false,
allowTypedFunctionExpressions:true,
allowHigherOrderFunctions:true,
},
],
create(context, [options]) {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,8 +33,9 @@ export default util.createRule<Options, MessageIds>({
docs: {
description:
'Require explicit accessibility modifiers on class properties and methods',
category: 'Best Practices',
recommended: 'error',
category: 'Stylistic Issues',
// too opinionated to be recommended
recommended: false,
},
messages: {
missingAccessibility:
Expand DownExpand Up@@ -82,7 +83,7 @@ export default util.createRule<Options, MessageIds>({
nodeType: string,
node: TSESTree.Node,
nodeName: string,
) {
): void {
context.report({
node: node,
messageId: messageId,
Expand DownExpand Up@@ -179,7 +180,7 @@ export default util.createRule<Options, MessageIds>({
*/
function checkParameterPropertyAccessibilityModifier(
node: TSESTree.TSParameterProperty,
) {
): void {
const nodeType = 'parameter property';
// HAS to be an identifier or assignment or TSC will throw
if (
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp