Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint-config: Disable naming-convention rule for non-js and non-ts files. #130

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 83 additions & 65 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,71 +68,6 @@ module.exports = {
// @typescript-eslint rules
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/naming-convention": [
"error",
// camelCase is the default
{
selector: "default",
format: ["camelCase"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// imports should be camelCase or PascalCase
{
selector: "import",
format: ["camelCase", "PascalCase"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// variables can be camelCase, PascalCase, or UPPER_CASE
{
selector: "variable",
format: ["camelCase", "PascalCase", "UPPER_CASE"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// destructuring variables from 3rd party sources which do not follow our naming conventions is okay
{ selector: "variable", format: null, modifiers: ["destructured"] },
// functions should be camelCase or PascalCase
{
selector: "function",
format: ["camelCase", "PascalCase"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// types should be PascalCase
{
selector: "typeLike",
format: ["PascalCase"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// enum members should be UPPER_CASE
{
selector: "enumMember",
format: ["UPPER_CASE"],
},
// 3rd party APIs do not always follow our naming conventions
{
selector: ["method", "parameter", "parameterProperty", "property"],
format: null,
},
// ignore properties that require quotes
{
selector: [
"classProperty",
"objectLiteralProperty",
"typeProperty",
"classMethod",
"objectLiteralMethod",
"typeMethod",
"accessor",
"enumMember",
],
format: null,
modifiers: ["requiresQuotes"],
},
],
"@typescript-eslint/no-non-null-assertion": "off",

// eslint-plugin-import rules
Expand Down Expand Up @@ -256,5 +191,88 @@ module.exports = {
"@typescript-eslint/no-namespace": "off",
},
},
{
files: [
"*.js",
"*.ts",
"*.jsx",
"*.tsx",
"*.cjs",
"*.cts",
"*.cjsx",
"*.ctsx",
"*.mjs",
"*.mts",
"*.mjsx",
"*.mtsx",
],
rules: {
"@typescript-eslint/naming-convention": [
"error",
// camelCase is the default
{
selector: "default",
format: ["camelCase"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// imports should be camelCase or PascalCase
{
selector: "import",
format: ["camelCase", "PascalCase"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// variables can be camelCase, PascalCase, or UPPER_CASE
{
selector: "variable",
format: ["camelCase", "PascalCase", "UPPER_CASE"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// destructuring variables from 3rd party sources which do not follow our naming conventions is okay
{ selector: "variable", format: null, modifiers: ["destructured"] },
// functions should be camelCase or PascalCase
{
selector: "function",
format: ["camelCase", "PascalCase"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// types should be PascalCase
{
selector: "typeLike",
format: ["PascalCase"],
leadingUnderscore: "allowSingleOrDouble",
trailingUnderscore: "allowSingleOrDouble",
},
// enum members should be UPPER_CASE
{
selector: "enumMember",
format: ["UPPER_CASE"],
},
// 3rd party APIs do not always follow our naming conventions
{
selector: ["method", "parameter", "parameterProperty", "property"],
format: null,
},
// ignore properties that require quotes
{
selector: [
"classProperty",
"objectLiteralProperty",
"typeProperty",
"classMethod",
"objectLiteralMethod",
"typeMethod",
"accessor",
"enumMember",
],
format: null,
modifiers: ["requiresQuotes"],
},
],
},
},
],
};
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kablamo/eslint-config",
"version": "0.0.14",
"version": "0.0.15",
"main": "index.js",
"repository": "https://github.com/KablamoOSS/kerosene/tree/master/packages/eslint-config",
"bugs": {
Expand Down