Skip to content

Commit

Permalink
Add config directory + config tests (#16)
Browse files Browse the repository at this point in the history
* Setup separate rules and configs diretories

* Move test side-by-side to rule

* Move lib into src, add devDependencies

* Add .nvmrc to version 16

* Add base scripts

* Add jest and node types, promise and sonjar plugins, ts-jest

* Add cypress config test, add husky hooks

* Add recommended tests

* Update rule definition and test based on new parser and identifiers

* Delete cypress changes (for now)

* Remove ts-jest

* Fix fixture.json gitignore

* use default exports, use more magic in tests

* Use JSDoc type

* Add node test workflow

* Set engines to match other downstream repos (e.g. typescript-eslint, jest)

* Expand JSDoc comment
  • Loading branch information
michaeljaltamirano authored Mar 29, 2022
1 parent 323b54f commit 1db9e3b
Show file tree
Hide file tree
Showing 15 changed files with 7,045 additions and 453 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 17.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --frozen-lockfile
- run: yarn test
132 changes: 3 additions & 129 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,133 +1,7 @@
const rules = require("./lib");

const importOrderBaseConfig = {
groups: [["builtin", "external"], "internal", ["parent", "sibling"]],
"newlines-between": "always",
warnOnUnassignedImports: false,
};

const importOrder = [
2,
{
groups: [["builtin", "external"], "internal", ["parent", "sibling"]],
"newlines-between": "always",
warnOnUnassignedImports: false,
},
];

/**
* TODO: If more distinct rulesets are needed, e.g. `plugin:curology/jest`,
* `plugin:curology/react`, we can expand on the exported config keys.
*/
const recommended = {
extends: [
"airbnb",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
],
parser: "@typescript-eslint/parser",
plugins: ["curology"],
rules: {
"@typescript-eslint/prefer-ts-expect-error": 2,
"arrow-parens": 0,
"class-methods-use-this": 0,
"comma-dangle": [2, "always-multiline"],
"consistent-return": 0,
"curology/no-single-letter-variable": 2,
"func-names": 0,
"function-paren-newline": 0,
"global-require": 0,
"id-length": 0,
"import/extensions": [2, "never"],
"import/no-cycle": 1,
"import/no-named-as-default-member": 1,
"import/no-unresolved": 0,
"import/order": [2, { ...importOrderBaseConfig }],
"import/prefer-default-export": 0,
"import/no-extraneous-dependencies": [2, { devDependencies: true }],
indent: 0,
"jsx-a11y/anchor-is-valid": 1,
"jsx-a11y/click-events-have-key-events": 1,
"jsx-a11y/img-redundant-alt": 1,
"jsx-a11y/no-static-element-interactions": 1,
"jsx-a11y/accessible-emoji": 1,
"max-len": 0,
"no-confusing-arrow": 0,
"no-console": 2,
"no-else-return": 1,
"no-plusplus": 1,
"no-static-element-interactions": 0,
"no-underscore-dangle": 1,
"object-curly-newline": 0,
"object-property-newline": [2, { allowAllPropertiesOnSameLine: true }],
"react/function-component-definition": 0,
"react/jsx-filename-extension": [1, { extensions: [".js", ".jsx"] }],
"react/jsx-fragments": [2, "element"],
"react/jsx-key": 2,
"react/jsx-no-useless-fragment": 0,
"react/jsx-one-expression-per-line": 0,
"react/jsx-props-no-spreading": 0,
"react/jsx-wrap-multilines": 0,
"react/no-array-index-key": 1,
"react/require-default-props": 2,
"react/sort-comp": 0,
"space-before-function-paren": 0,
},
settings: {
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
},
};

const cypress = {
...recommended,
extends: ["plugin:cypress/recommended", ...recommended.extends],
parser: "@typescript-eslint/parser",
plugins: ["cypress"],
rules: {
...recommended.rules,
"cypress/no-assigning-return-values": 2,
"cypress/no-unnecessary-waiting": 2,
"cypress/no-async-tests": 2,
"cypress/assertion-before-screenshot": 2,
"cypress/require-data-selectors": 0,
"cypress/no-force": 1,
"cypress/no-pause": 2,
"@typescript-eslint/ban-ts-ignore": 0,
camelcase: 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-unused-vars": [
1,
{
argsIgnorePattern: "^_",
},
],
"import/order": [
2,
{
...importOrderBaseConfig,
pathGroups: [
{
pattern: "{constants,integration,fixtures}/**",
group: "parent",
position: "before",
},
],
pathGroupsExcludedImportTypes: [],
},
],
"no-console": "off", // `cypress-log-to-output` makes console usage useful for debugging
},
env: {
"cypress/globals": true,
},
};
const rules = require("./lib/rules");
const configs = require("./lib/configs");

module.exports = {
configs: {
cypress,
recommended,
},
configs,
rules,
};
83 changes: 0 additions & 83 deletions lib/rules/no-single-letter-variable.js

This file was deleted.

28 changes: 26 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"homepage": "https://github.com/PocketDerm/eslint-plugin-curology",
"engines": {
"node": "16.x"
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"main": "index.js",
"peerDependencies": {
Expand All @@ -42,12 +42,36 @@
"eslint-plugin-react-hooks": "^4.3.0"
},
"devDependencies": {
"husky": "^7.0.0",
"@babel/eslint-parser": "^7.17.0",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.23",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/experimental-utils": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"eslint": "^8.11.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-curology": "^0.1.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.2",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-sonarjs": "^0.12.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
"lint-staged": "^12.3.7",
"prettier": "^2.6.1",
"typescript": "^4.6.3",
"yarn-deduplicate": "^4.0.0"
},
"scripts": {
"test": "yarn run jest src",
"prepare": "husky install"
}
}
5 changes: 5 additions & 0 deletions src/configs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const recommended = require("./recommended");

module.exports = {
recommended,
};
Loading

0 comments on commit 1db9e3b

Please sign in to comment.