Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
major version changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukpsaxo committed May 12, 2020
1 parent bab8f58 commit c10400a
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 1,240 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.0] - 2020-05-
- Remove rules replaced by prettier - jsx-conditional-indent, jsx-conditional-newline, jsx-conditional-parens, jsx-curly-spacing-opinionated
- Rename jsx-enforce-spec-describe to enforce-spec-describe

## [1.8.0] - 2020-05-04
- Add new import-path-type rule

Expand All @@ -27,7 +31,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Add clean-jest-snapshots rule

## [1.2.0] - 2018-08-20
- Add jsx-enforce-spec-describe rule
- Add enforce-spec-describe rule

## [1.1.1] - 2018-08-05
- Fix reliance on a eslint function that was in a file that was renamed in eslint v5.2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ These rules are purely matters of style and are quite subjective.
* [jsx-conditional-parens](docs/rules/jsx-conditional-parens.md): Require no parens when JSX is used within a conditional.
* [jsx-curly-spacing-opinionated](docs/rules/jsx-curly-spacing-opinionated.md): Require particular spacing rules that cannot be defined using jsx-curly-spacing inside eslint-plugin-react.
* [jsx-enforce-prop-usage](docs/rules/jsx-enforce-prop-usage.md): Enforce how props are used. Can help to enforce extracting inline function calls to variables.
* [jsx-enforce-spec-describe](docs/rules/jsx-enforce-spec-describe.md): Enforces *.spec.* unit tests top level describe method to have first argument matching path of file under test.
* [enforce-spec-describe](docs/rules/enforce-spec-describe.md): Enforces *.spec.* unit tests top level describe method to have first argument matching path of file under test.
* [clean-jest-snapshots](docs/rules/clean-jest-snapshots.md): Checks for code smells in jest snapshots.
* [cy-viewport-max](docs/rules/cy-viewport-max.md): Enforces a limit on cypress viewport.
* [cy-viewport-literals](docs/rules/cy-viewport-literals.md): Enforces the use of literals when setting cypress viewport.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# jsx-enforce-spec-describe
# enforce-spec-describe

The eslint spec describe rule enforces *.spec.* unit tests top level describe method to have first argument matching path of file under test.

The rule accepts _topLevelDir_ option which allows to suggest expected fix. Example:

```json
"saxo/jsx-enforce-spec-describe": [
"saxo/enforce-spec-describe": [
"error",
{
"topLevelDir": "Project/Source/FrontendApp/js/"
Expand All @@ -25,7 +25,7 @@ The following patterns are considered problems:

```js
/*
"saxo/jsx-enforce-spec-describe": [
"saxo/enforce-spec-describe": [
"error",
{
"topLevelDir": "SampleProject/Source/SampleProject.App/js/"
Expand Down Expand Up @@ -56,7 +56,7 @@ The following patterns are not considered warnings:

```js
/*
"saxo/jsx-enforce-spec-describe": [
"saxo/enforce-spec-describe": [
"error",
{
"topLevelDir": "SampleProject/Source/SampleProject.App/js/"
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/import-path-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The following patterns are considered problems:

```js
/*
"saxo/jsx-enforce-spec-describe": [
"saxo/enforce-spec-describe": [
"error",
{
"parts": 4,
Expand All @@ -44,7 +44,7 @@ The following patterns are not considered warnings:

```js
/*
"saxo/jsx-enforce-spec-describe": [
"saxo/enforce-spec-describe": [
"error",
{
"parts": 4,
Expand Down
59 changes: 0 additions & 59 deletions docs/rules/jsx-conditional-indent.md

This file was deleted.

32 changes: 0 additions & 32 deletions docs/rules/jsx-conditional-newline.md

This file was deleted.

57 changes: 0 additions & 57 deletions docs/rules/jsx-conditional-parens.md

This file was deleted.

53 changes: 0 additions & 53 deletions docs/rules/jsx-curly-spacing-opinionated.md

This file was deleted.

25 changes: 18 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,28 @@ module.exports = {
processors: {
'.snap': {
preprocess: (source) => [source],
postprocess: (messages) => messages[0].filter((message) => message.ruleId.indexOf('snapshot') !== -1),
postprocess: (messages) =>
messages[0].filter(
(message) => message.ruleId.indexOf('snapshot') !== -1
),
},
},
rules: rules.reduce((ruleObj, rule) =>
Object.assign(ruleObj, { [rule]: require(`./rules/${rule}`) })
, {}),
rules: rules.reduce(
(ruleObj, rule) =>
Object.assign(ruleObj, { [rule]: require(`./rules/${rule}`) }),
{}
),
configs: {
recommended: {
rules: {
'@saxo/saxo/cy-viewport-max': ['error', { maxWidth: 1600, maxHeight: 1160 }],
'@saxo/saxo/cy-viewport-presets': ['error', { allowed: ['phone', 'tablet', 'desktop'] }],
'@saxo/saxo/cy-viewport-max': [
'error',
{ maxWidth: 1600, maxHeight: 1160 },
],
'@saxo/saxo/cy-viewport-presets': [
'error',
{ allowed: ['phone', 'tablet', 'desktop'] },
],
'@saxo/saxo/cy-viewport-literals': 'error',
'@saxo/saxo/no-cy-pause': 'error',
'@saxo/saxo/string-constant-types': 'error',
Expand All @@ -30,7 +41,7 @@ module.exports = {
'@saxo/saxo/jsx-conditional-parens': 'error',
'@saxo/saxo/jsx-curly-spacing-opinionated': 'error',
'@saxo/saxo/jsx-enforce-prop-usage': 'warn',
'@saxo/saxo/jsx-enforce-spec-describe': 'warn',
'@saxo/saxo/enforce-spec-describe': 'warn',
},
},
},
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions src/rules/import-path-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
},
],
messages: {
incorrectPath: "Path should be '{{expectedPath}}'",
incorrectPath: 'Path should be \'{{expectedPath}}\'',
},
fixable: true,
},
Expand All @@ -32,8 +32,8 @@ module.exports = {

return {
ImportDeclaration(node) {
let cwd = context.options[0].cwd || context.getCwd();
let fileName = path
const cwd = context.options[0].cwd || context.getCwd();
const fileName = path
.relative(cwd, context.getFilename())
.replace(/\\/g, '/');

Expand All @@ -43,9 +43,9 @@ module.exports = {
const baseDir = dirName.split('/').slice(0, parts).join('/');

const importPath = node.source.value;
const resolvedImportPath = importPath.startsWith('.')
? path.join(dirName, importPath).replace(/\\/g, '/')
: importPath;
const resolvedImportPath = importPath.startsWith('.') ?
path.join(dirName, importPath).replace(/\\/g, '/') :
importPath;

let expectedPath = importPath;

Expand Down
Loading

0 comments on commit c10400a

Please sign in to comment.