Skip to content

Commit

Permalink
refactor: clean up eslint and prettier
Browse files Browse the repository at this point in the history
- goodby prettier
  • Loading branch information
yoshinorin committed May 1, 2023
1 parent a2c92cb commit 305908d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 296 deletions.
186 changes: 25 additions & 161 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,171 +1,35 @@
module.exports = {
root: true,
plugins: [
'eslint-plugin',
'@typescript-eslint',
'jest',
'import',
'eslint-comments',
],
env: {
es6: true,
node: true,
},
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "mocha"],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
rules: {
//
// our plugin :D
//

'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/unbound-method': 'off',

//
// eslint base
//

'comma-dangle': ['error', 'always-multiline'],
curly: ['error', 'all'],
'no-mixed-operators': 'error',
'no-console': 'error',
'no-process-exit': 'error',

//
// eslint-plugin-eslint-comment
//

// require a eslint-enable comment for every eslint-disable comment
'eslint-comments/disable-enable-pair': [
'error',
{
allowWholeFile: true,
},
],
// disallow a eslint-enable comment for multiple eslint-disable comments
'eslint-comments/no-aggregating-enable': 'error',
// disallow duplicate eslint-disable comments
'eslint-comments/no-duplicate-disable': 'error',
// disallow eslint-disable comments without rule names
'eslint-comments/no-unlimited-disable': 'error',
// disallow unused eslint-disable comments
'eslint-comments/no-unused-disable': 'error',
// disallow unused eslint-enable comments
'eslint-comments/no-unused-enable': 'error',
// disallow ESLint directive-comments
'eslint-comments/no-use': [
'error',
{
allow: [
'eslint-disable',
'eslint-disable-line',
'eslint-disable-next-line',
'eslint-enable',
],
},
],

//
// eslint-plugin-import
//

// disallow non-import statements appearing before import statements
'import/first': 'error',
// Require a newline after the last import/require in a group
'import/newline-after-import': 'error',
// Forbid import of modules using absolute paths
'import/no-absolute-path': 'error',
// disallow AMD require/define
'import/no-amd': 'error',
// forbid default exports
'import/no-default-export': 'error',
// Forbid the use of extraneous packages
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
peerDependencies: true,
optionalDependencies: false,
},
],
// Forbid mutable exports
'import/no-mutable-exports': 'error',
// Prevent importing the default as if it were named
'import/no-named-default': 'error',
// 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
'import/prefer-default-export': 'off', // we want everything to be named
},
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: false,
},
project: './tsconfig.base.json',
},
ignorePatterns: ["out/*", "*.js"],
overrides: [
{
files: [
'packages/eslint-plugin-tslint/tests/**/*.ts',
'packages/eslint-plugin/tests/**/*.test.ts',
'packages/parser/tests/**/*.ts',
'packages/typescript-estree/tests/**/*.ts',
],
env: {
'jest/globals': true,
},
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-alias-methods': 'error',
'jest/no-identical-title': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-jest-import': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-test-callback': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/prefer-spy-on': 'error',
'jest/valid-expect': 'error',
},
},
{
files: [
'packages/eslint-plugin/tests/**/*.test.ts',
'packages/eslint-plugin-tslint/tests/**/*.spec.ts',
],
rules: {
'eslint-plugin/no-identical-tests': 'error',
},
},
{
files: [
'packages/eslint-plugin/src/rules/**/*.ts',
'packages/eslint-plugin/src/configs/**/*.ts',
'packages/eslint-plugin-tslint/src/rules/**/*.ts',
],
files: ["*.ts"],
rules: {
// specifically for rules - default exports makes the tooling easier
'import/no-default-export': 'off',
},
},
{
files: ['**/tools/**/*.ts', '**/tests/**/*.ts'],
rules: {
// allow console logs in tools and tests
'no-console': 'off',
"@ts-ignore": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-non-null-assertion": "error",
"guard-for-in": "error",
"no-var": "error",
curly: "error",
"no-useless-escape": "off",
"mocha/no-exclusive-tests": "error",
},
},
],
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
uses: actions/setup-node@v3
- name: Install Dependencies
run: npm install
- name: Lint
run: npm run lint
- name: Compile TypeScript
run: npm run compile
- name: Run headless tests - specific version
Expand Down
12 changes: 0 additions & 12 deletions .prettierignore

This file was deleted.

10 changes: 0 additions & 10 deletions .prettierrc.json

This file was deleted.

2 changes: 0 additions & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ tslint.json
images/icon.svg
images/image.gif
images/original_image.gif
.prettierignore
.prettierrc.json
.github
Loading

0 comments on commit 305908d

Please sign in to comment.