forked from stencil-community/stencil-eslint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'github/master' into feature/update_feat…
…ures # Conflicts: # README.md # docs/async-methods.md # docs/ban-prefix.md # docs/class-pattern.md # docs/decorators-context.md # docs/decorators-style.md # docs/element-type.md # docs/host-data-deprecated.md # docs/methods-must-be-public.md # docs/no-unused-watch.md # docs/own-methods-must-be-private.md # docs/own-props-must-be-private.md # docs/prefer-vdom-listener.md # docs/props-must-be-public.md # docs/props-must-be-readonly.md # docs/render-returns-host.md # docs/required-jsdoc.md # docs/required-prefix.md # docs/reserved-member-names.md # docs/single-export.md # docs/strict-mutable.md # package-lock.json # package.json # src/configs/index.ts # src/configs/recommended.ts # src/rules/async-methods.ts # src/rules/decorators-style.ts # src/rules/element-type.ts # src/rules/index.ts # src/rules/methods-must-be-public.ts # src/rules/no-unused-watch.ts # src/rules/own-methods-must-be-private.ts # src/rules/own-props-must-be-private.ts # src/rules/prefer-vdom-listener.ts # src/rules/props-must-be-public.ts # src/rules/render-returns-host.ts # src/rules/required-jsdoc.ts # src/rules/required-prefix.ts # src/rules/reserved-member-names.ts # src/rules/strict-mutable.ts # src/utils.ts # tests/lib/rules/element-type/element-type.spec.ts # tests/lib/rules/element-type/element-type.wrong.tsx # tests/lib/rules/strict-mutable/strict-mutable.good.tsx # tsconfig.json
- Loading branch information
Showing
29 changed files
with
813 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import nodeResolve from 'rollup-plugin-node-resolve'; | ||
export default { | ||
input: 'dist/build/index.js', | ||
plugins: [ | ||
nodeResolve({ | ||
preferBuiltins: true | ||
}) | ||
], | ||
treeshake: { | ||
pureExternalModules: true | ||
}, | ||
external: [ | ||
'eslint', | ||
'typescript', | ||
'tsutils', | ||
'eslint-utils' | ||
], | ||
output: { | ||
file: 'dist/index.js', | ||
format: 'commonjs' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export default { | ||
overrides: [ | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
'jsx': true | ||
} | ||
}, | ||
plugins: [ | ||
'@stencil' | ||
], | ||
rules: { | ||
'@stencil/async-methods': 2, | ||
'@stencil/ban-prefix': [2, ['stencil', 'stnl', 'st']], | ||
'@stencil/decorators-context': 2, | ||
'@stencil/element-type': 2, | ||
'@stencil/host-data-deprecated': 2, | ||
'@stencil/methods-must-be-public': 2, | ||
'@stencil/no-unused-watch': 2, | ||
'@stencil/prefer-vdom-listener': 2, | ||
'@stencil/props-must-be-public': 2, | ||
'@stencil/render-returns-host': 2, | ||
'@stencil/reserved-member-names': 2, | ||
'@stencil/single-export': 2, | ||
} | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import base from './base'; | ||
import recommended from './recommended'; | ||
import strict from './strict'; | ||
|
||
export default { | ||
recommended | ||
base, | ||
recommended, | ||
strict | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
export default { | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@stencil/recommended", | ||
], | ||
rules: { | ||
// Resets | ||
"@typescript-eslint/camelcase": 0, | ||
"@typescript-eslint/explicit-function-return-type": 0, | ||
"@typescript-eslint/ban-ts-ignore": 0, | ||
"@typescript-eslint/no-this-alias": 0, | ||
"@typescript-eslint/no-non-null-assertion": 0, | ||
"@typescript-eslint/no-unused-vars": 0, | ||
"@typescript-eslint/no-empty-interface": 0, | ||
"@typescript-eslint/no-use-before-define": 0, | ||
"@typescript-eslint/no-explicit-any": 0, | ||
"no-constant-condition": 0, | ||
|
||
|
||
// Best practices | ||
"no-shadow": 2, | ||
"require-atomic-updates": 2, | ||
"no-var": 2, | ||
"prefer-object-spread": 2, | ||
"no-nested-ternary": 2, | ||
"no-duplicate-imports": 2, | ||
|
||
// General formatting | ||
"indent": [2, 2], | ||
"no-trailing-spaces": 2, | ||
"curly": [2, "all"], | ||
"comma-spacing": 2, | ||
"comma-style": 2, | ||
"computed-property-spacing": 2, | ||
"comma-dangle": [2, "always-multiline"], | ||
"func-style": [2, "expression", { "allowArrowFunctions": true }], | ||
"multiline-ternary": [2, "always-multiline"], | ||
"operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }], | ||
"linebreak-style": 2, | ||
"space-in-parens": 2, | ||
"@typescript-eslint/semi": 2, | ||
"@typescript-eslint/brace-style": 2, | ||
"@typescript-eslint/func-call-spacing": 2, | ||
|
||
// JSX formatting | ||
"react/jsx-closing-tag-location": 2, | ||
"react/jsx-curly-newline": [2, "never"], | ||
"react/jsx-closing-bracket-location": 2, | ||
"react/jsx-curly-spacing": [2, {"when": "never", "children": true}], | ||
"react/jsx-boolean-value": [2, "never"], | ||
"react/jsx-child-element-spacing": 2, | ||
"react/jsx-indent-props": [2, "first"], | ||
"react/jsx-props-no-multi-spaces": 2, | ||
"react/jsx-equals-spacing": [2, "never"], | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
import rules from './rules'; | ||
import configs from './configs'; | ||
|
||
export = { | ||
export { | ||
rules, | ||
configs | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Rule } from 'eslint'; | ||
|
||
const rule: Rule.RuleModule = { | ||
meta: { | ||
docs: { | ||
description: 'This rule catches exports of const enums', | ||
category: 'Possible Errors', | ||
recommended: true | ||
}, | ||
schema: [], | ||
type: 'problem' | ||
}, | ||
|
||
create(context): Rule.RuleListener { | ||
return { | ||
'ExportNamedDeclaration > TSEnumDeclaration[const]': (node: any) => { | ||
context.report({ | ||
node: node, | ||
message: `Exported const enums are not allowed` | ||
}); | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
export default rule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Rule } from 'eslint'; | ||
|
||
const rule: Rule.RuleModule = { | ||
meta: { | ||
docs: { | ||
description: 'This rule catches function calls at the top level', | ||
category: 'Possible Errors', | ||
recommended: false | ||
}, | ||
schema: [ | ||
{ | ||
type: 'array', | ||
items: { | ||
type: 'string' | ||
}, | ||
minLength: 0, | ||
additionalProperties: false | ||
} | ||
], | ||
type: 'suggestion' | ||
}, | ||
|
||
create(context): Rule.RuleListener { | ||
const shouldSkip = /\b(spec|e2e|test)\./.test(context.getFilename()); | ||
const skipFunctions = context.options[0] || DEFAULTS; | ||
if (shouldSkip) { | ||
return {}; | ||
} | ||
return { | ||
'CallExpression': (node: any) => { | ||
if (skipFunctions.includes(node.callee.name)) { | ||
return; | ||
} | ||
if (!isInScope(node)) { | ||
context.report({ | ||
node: node, | ||
message: `Call expressions at the top-level should be avoided.` | ||
}); | ||
} | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
const isInScope = (n: any): boolean => { | ||
const type = n.type; | ||
if ( | ||
type === 'ArrowFunctionExpression' || | ||
type === 'FunctionDeclaration' || | ||
type === 'ClassDeclaration' || | ||
type === 'ExportNamedDeclaration' | ||
) { | ||
return true; | ||
} | ||
n = n.parent; | ||
if (n) { | ||
return isInScope(n); | ||
} | ||
return false; | ||
} | ||
|
||
const DEFAULTS = ['describe', 'test', 'bind']; | ||
|
||
export default rule; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.