Skip to content

Commit

Permalink
Re-configure ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
sankichi92 committed May 22, 2021
1 parent 00f51f3 commit d2c6ce8
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 49 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

24 changes: 19 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
module.exports = {
env: {
browser: true,
es6: true,
es2021: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
globals: {},
parser: 'babel-eslint',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 12,
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {},
overrides: [
{
files: ['webpack.config.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
},
},
{
files: ['*.js'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
],
};
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"singleQuote": true
}
5 changes: 0 additions & 5 deletions .prettierrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.tabSize": 2,

"ruby.lint": {
"rubocop": {
"useBundler": true
Expand Down
18 changes: 13 additions & 5 deletions app/javascript/controllers/itunes_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ export default class extends Controller {
_fetchSearchResult() {
const encodedTrackName = encodeURIComponent(this.trackName);
const encodedArtistName = encodeURIComponent(this.artistName);
return fetch(`https://itunes.apple.com/search?term=${encodedTrackName}+${encodedArtistName}&country=JP&media=music&entity=song&lang=ja_jp`, {
redirect: 'manual',
}).then((response) => {
return fetch(
`https://itunes.apple.com/search?term=${encodedTrackName}+${encodedArtistName}&country=JP&media=music&entity=song&lang=ja_jp`,
{
redirect: 'manual',
}
).then((response) => {
if (response.ok) {
return response.json();
} else if (response.redirected) {
Expand All @@ -42,7 +45,10 @@ export default class extends Controller {

_findAppropriateResult(results) {
let result = results.find((res) => {
return res.trackName.toLowerCase() === this.trackName.toLowerCase() && res.artistName.toLowerCase() === this.artistName.toLowerCase();
return (
res.trackName.toLowerCase() === this.trackName.toLowerCase() &&
res.artistName.toLowerCase() === this.artistName.toLowerCase()
);
});

if (result === undefined) {
Expand All @@ -63,7 +69,9 @@ export default class extends Controller {
this.artworkTarget.setAttribute('src', result.artworkUrl100);
this.audioTarget.setAttribute('src', result.previewUrl);

this.linkTargets.forEach((element) => element.setAttribute('href', `${result.trackViewUrl}&at=1001lKQU&app=itunes`));
this.linkTargets.forEach((element) =>
element.setAttribute('href', `${result.trackViewUrl}&at=1001lKQU&app=itunes`)
);

this.element.classList.remove('d-none');
}
Expand Down
4 changes: 1 addition & 3 deletions config/favicon.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
},
"app_name": "LiveLog"
},
"desktop_browser": [

],
"desktop_browser": [],
"windows": {
"picture_aspect": "no_change",
"background_color": "#da532c",
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"private": true,
"scripts": {
"build": "webpack",
"lint": "eslint *.config.js .*.js app/javascript"
"format": "prettier '**/*.{json,js,ts}' --ignore-path .gitignore --write && eslint . --ext .js,.ts --ignore-path .gitignore --fix",
"lint": "prettier '**/*.{json,js,ts}' --ignore-path .gitignore --check && eslint . --ext .js,.ts --ignore-path .gitignore && tsc"
},
"dependencies": {
"@rails/activestorage": "^6.1.3",
Expand All @@ -18,10 +19,13 @@
"stimulus": "^2.0.0"
},
"devDependencies": {
"@types/rails__activestorage": "^6.0.0",
"@types/rails__ujs": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"prettier": "^2.3.0",
"ts-loader": "^9.2.1",
"tsconfig-paths-webpack-plugin": "^3.5.1",
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"compilerOptions": {
"target": "ES2015",
"allowJs": true,
"checkJs": true,
"sourceMap": true,
"noEmit": true,
"strict": true,
Expand Down
Loading

0 comments on commit d2c6ce8

Please sign in to comment.