Skip to content

Commit

Permalink
test: add tests for unicorn/filename-case rule
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMiguel committed Jul 27, 2023
1 parent d1746d4 commit dab33f1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rules/unicorn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
extends: ['plugin:unicorn/recommended'],
rules: {
'unicorn/filename-case': 'off',
'unicorn/filename-case': 0,
},
}
1 change: 1 addition & 0 deletions test/fixtures/import/prefer-default-export.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Rule: When there is only a single export from a module, prefer using default export over named export.
// Message: Prefer default export.
// ESLint config Cecilia: This rule should be ignored.
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md

export const foo = 'foo'
1 change: 1 addition & 0 deletions test/fixtures/jsdoc/require-example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Rule: Requires that all functions have examples.
// Message: Missing JSDoc @example description.
// ESLint config Cecilia: This rule should be ignored.
// https://github.com/gajus/eslint-plugin-jsdoc#require-example

/* eslint-disable no-unused-vars */
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/react/react-in-jsx-scope.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Rule: Prevent missing React when using JSX
// Message: 'React' must be in scope when using JSX.
// ESLint config Cecilia: This rule should be ignored.
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md

export default function SomeComponent() {
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/unicorn/filenameCase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Rule: Enforces all linted files to have their names in a certain case style and lowercase file extension. The default is kebabCase.
// Message: Filename is not in kebab case. Rename it to `filename-case.js`.
// ESLint config Cecilia: This rule should be ignored.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md

/* eslint-disable no-console */
console.log('hello')
16 changes: 13 additions & 3 deletions test/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test('camelcase rule', async () => {
)
})

test('import/prefer-default-export rule', async () => {
test('ignore import/prefer-default-export rule', async () => {
const ruleId = 'import/prefer-default-export'
const result = await fetchTestFiles(ruleId)
const { messages } = result[0]
Expand All @@ -76,7 +76,7 @@ test('import/prefer-default-export rule', async () => {
)
})

test('jsdoc/require-example rule', async () => {
test('ignore jsdoc/require-example rule', async () => {
const ruleId = 'jsdoc/require-example'
const result = await fetchTestFiles(ruleId)
const { messages } = result[0]
Expand Down Expand Up @@ -116,7 +116,7 @@ test('react-hooks/rules-of-hooks', async () => {
)
})

test('react/react-in-jsx-scope', async () => {
test('ignore react/react-in-jsx-scope', async () => {
const ruleId = 'react/react-in-jsx-scope'
const result = await fetchTestFiles(ruleId)
const { messages } = result[0]
Expand Down Expand Up @@ -145,3 +145,13 @@ test('unicorn/catch-error-name', async () => {
messages[0] && messages[0].message,
)
})

test('ignore unicorn/filename-case', async () => {
const filename = 'unicorn/filenameCase'
const result = await fetchTestFiles(filename)
const { messages } = result[0]
expect(messages[0] && messages[0].ruleId).toBe(
undefined,
messages[0] && messages[0].message,
)
})

0 comments on commit dab33f1

Please sign in to comment.